Horje
C# Program For Check Total Occurrence Of A Number In An Array Code Example
C# Program For Check Total Occurrence Of A Number In An Array
using System;   
using System.Linq;   
namespace CheckOccurrenceOfNumberInArray  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            int[] array = { 1, 20, 15, 23, 15, 14, 26, 188,175,12, 36, 78, 15, 3, 5, 91, 822, 100, 1202, 78, 95, 12, 123, 12, 14, 25, 36, 15, 36, 95, 45, 10, 20, 30, 04, 50, 40, 60, 70, 80, 90, 104 };  
            Console.WriteLine("Your Array...");  
            for (int i = 0; i < array.Length; i++)  
            {  
                Console.Write(array[i] + " ");  
            }  
            Console.WriteLine("\n\n");  
            Console.Write("Enter number to check occurrence  :  ");  
            int number = Convert.ToInt32(Console.ReadLine());  
  
            int occurrences = array.Count(x => x == number);  
            Console.WriteLine("Occurrence of {0} in given array is {1}", number, occurrences);  
            Console.ReadKey();  
        }  
    }  
} 




Csharp

Related
linq sum Code Example linq sum Code Example
dicionĂ¡rio c# foreach keyvaluepair Code Example dicionĂ¡rio c# foreach keyvaluepair Code Example
unity list get item at index Code Example unity list get item at index Code Example
editorfor date format mvc Code Example editorfor date format mvc Code Example
sum of digit of number c# Code Example sum of digit of number c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10