Code Snippet - Count Instances of a Value in an Array

This method checks to see if the given value is within the array that it is passed. For every occurrence of the value in the array, the counter increases. The method will return an int with the count of the given value in an int[].

In each loop the next item in the array is compared against the value that is being searched for. if the value matches the search term, then the counter increases by one. The count is then returned at the end of the method.

///Accepts an array of ints of values to be checked, and an int which is the value to check for. 
///Returns the number of times that the value appears in the array
/// <param name="numbers">The array of numbers to be checked</param>
/// <param name="value">The integer value to check for</param>
/// <returns>(int) count</returns>
public static int InstanceOfNumber(int[] numbers, int value)
    int count =0;
        foreach(int i in numbers)
             if (value == i)
    return count;

This method obviously uses ints, but it would be jsut as easy to use doubles or any other value type including chars in a char array.