Advertisement
alexpeevk9

1.Composing Methods - Problem Code

Dec 27th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. namespace FirstExample
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             string[] people = new string[3] { "Don", "Steve", "Michael" };
  10.             Console.WriteLine(FoundPerson(people));
  11.         }
  12.  
  13.         static string FoundPerson(string[] people)
  14.         {
  15.             for (int i = 0; i < people.Length; i++)
  16.             {
  17.                 if (people[i].Equals("Don"))
  18.                 {
  19.                     return "Don";
  20.                 }
  21.                 if (people[i].Equals("John"))
  22.                 {
  23.                     return "John";
  24.                 }
  25.                 if (people[i].Equals("Kent"))
  26.                 {
  27.                     return "Kent";
  28.                 }
  29.             }
  30.             return String.Empty;
  31.         }
  32.  
  33.     }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement