title: Combine two Method in C#
body: <p>So i have following two method's, i was thinking is there any way i can reduce the code to one method and <strong>optimize code</strong></p>
  
  <p>Both Method's are almost same except the <strong>if statement</strong></p>
  
  <pre><code>private void RepeatSearch()
  {
    string optionRead = string.Empty;
    do
    {
     Console.WriteLine("\nPress \"Y\" to Continue ,\"M\" For Main Menu\n");
     Console.Write("Your Choice : ");
    optionRead = Console.ReadLine().ToLower();
     if (optionRead == "y")
      {
       SearchData();
      }
      if (optionRead == "m")
       {
         m.SelectOption();
       }
     else
       {
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("\nInvalid Option.Enter M or Y\n");
        Console.ResetColor();
       }
    } while (optionRead != "m" || optionRead != "y");
  }
  
  private void RepeatAdd()
  {
    string optionRead = string.Empty;
    do
    {
     Console.WriteLine("\nPress \"Y\" to Continue ,\"M\" For Main Menu\n");
     Console.Write("Your Choice : ");
    optionRead = Console.ReadLine().ToLower();
     if (optionRead == "y")
      {
        AddData();
      }
      if (optionRead == "m")
       {
         m.SelectOption();
       }
     else
       {
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("\nInvalid Option.Enter M or Y\n");
        Console.ResetColor();
       }
    } while (optionRead != "m" || optionRead != "y");
  }
  </code></pre>