// Set up Console UI (CUI)
Console.Title = "My Rocking App";
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("*************************************");
Console.WriteLine("***** Welcome to My Rocking App *****");
Console.WriteLine("*************************************");
Console.BackgroundColor = ConsoleColor.Black;
// Wait for Enter key to be pressed.
Console.ReadLine();
}
While there is nothing wrong with the preceding code as it now stands, imagine that you want
to display this welcome message at various places throughout your program. Rather than retyping
the same exact console user interface logic, it would be ideal to have a helper function that could be
called to do so. Given this, you will apply the Extract Method refactoring to your existing code.
First, select each code statement within Main() (except the final call to Console.ReadLine())
using the editor. Now, right-click the selected text and select the Extract Method option within the
Refactor context menu (see Figure 2-22).
Do'stlaringiz bilan baham: |