Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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("

");  
            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();  
        }  
    }  
} 
Comment

PREVIOUS NEXT
Code Example
Csharp :: csharp sleep code 1 second 
Csharp :: unity detect keyboard not mouse 
Csharp :: solidity get address of contract 
Csharp :: what is public static void 
Csharp :: c# list remove item based on property duplicate 
Csharp :: Celsius to Fahrenheit c# 
Csharp :: unit test throw exception c# xunit 
Csharp :: make string uppercase c# 
Csharp :: C# Unit test IConfiguration 
Csharp :: how to save datagridview data to database in c# windows application 
Csharp :: c# string to b64 
Csharp :: c# distinct by property 
Csharp :: if number negative c sharp 
Csharp :: Unity Destroy gameObject upon collision 
Csharp :: get device connected to player input unity 
Csharp :: c# enum to int array 
Csharp :: order by length descending C# 
Csharp :: foreach enum 
Csharp :: c# check lenght 
Csharp :: unity call function on animation onstateexit 
Csharp :: unity 3d camera movement script 
Csharp :: how to get the transform of an object in unity 
Csharp :: c# how to find character in string 
Csharp :: change image of button c# 
Csharp :: fluent assertion exception 
Csharp :: c# execute shell command 
Csharp :: unity interfaces 
Csharp :: how to make button in asp.net to go to other page 
Csharp :: how to make an ui to follow gameobject 
Csharp :: wpf toolbar disable overflow 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =