Advertisement
alexpeevk9

1.Composing Methods - Refactored Code

Dec 27th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. namespace FirstExampleRefactored
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  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.         static string FoundPerson(string[] people)
  13.         {
  14.             List<string> candidates = new List<string>() { "Don", "John", "Kent" };
  15.  
  16.             for (int i = 0; i < people.Length; i++)
  17.             {
  18.                 if (candidates.Contains(people[i]))
  19.                 {
  20.                     return people[i];
  21.                 }
  22.             }
  23.  
  24.             return String.Empty;
  25.         }
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement