Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] myarray = { 1, 4, 5, 6, 5, 8, 5, 6 };
- Console.WriteLine(Count(myarray, 5));
- }
- static int Count(int[] numbers, int x)
- {
- if (numbers == null || numbers.Length == 0)
- {
- return 0;
- }
- int count = 0;
- foreach (var item in numbers)
- {
- if (x.Equals(item))
- {
- count++;
- }
- }
- return count;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement