Advertisement
aslen

Untitled

Feb 28th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Collections;
  4. namespace Forum
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] str1 = { "Cat", "Dog", "Pig", "Horse", "Wolf", "Elephant" };
  11.             Animal letter = new Animal();
  12.             int res = letter.NumberOfRights(str1);
  13.             Console.WriteLine("Letter \'a\' found {0}" ,res);
  14.             Console.ReadLine();
  15.            
  16.  
  17.         }
  18.     }
  19.     class Animal
  20.     {
  21.         public int NumberOfRights(string[]str1)
  22.         {
  23.             int number = 0;
  24.             string compare = "a";
  25.             foreach (var item in str1)
  26.             {
  27.                 if (item.Contains(compare))
  28.                 {
  29.                     number++;
  30.                 }
  31.             }
  32.             return number;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement