Advertisement
callumbinner22

pg347 Task 4 (error analysis needed.)

Dec 5th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Please enter a series of numbers seperated by a ,");
  14.             string input = Console.ReadLine();
  15.             string[] numbers = input.Split(',');
  16.             Array.Sort(numbers);
  17.             Console.WriteLine("Please enter number you would like to identify");
  18.             int count1 = Convert.ToInt32(Console.ReadLine());
  19.             //Console.WriteLine(Count<T>(count1));
  20.             foreach (var item in numbers)
  21.             {
  22.                 Console.WriteLine(item.ToString());
  23.             }
  24.         }
  25.             static int Count< T > (T[] numbers, int value)
  26.         {
  27.                 if (numbers == null || numbers.Length == 0)
  28.             {
  29.                     return 0;
  30.                 }
  31.  
  32.                 int count = 0;
  33.                 foreach (var item in numbers)
  34.                 {
  35.                     if (value.Equals(item))
  36.                     {
  37.                         count++;
  38.                     }
  39.                 }
  40.  
  41.                 return count;
  42.             }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement