If something like the following is written somewhere,
int busylevel; DayOfWeek day = DateTime.Now.DayOfWeek; switch (day) { case DayOfWeek.Sunday: busylevel = 1; break; case DayOfWeek.Monday: busylevel = 5; break; case DayOfWeek.Tuesday: busylevel = 5; break; case DayOfWeek.Wednesday: busylevel = 4; break; case DayOfWeek.Thursday: busylevel = 4; break; case DayOfWeek.Friday: busylevel = 3; break; case DayOfWeek.Saturday: busylevel = 2; break; default: busylevel = -1; break; }
the code block selected, and the Extract Method From Code Block command is called up with a method name being given, the following code will be created into the same type where the above code block is:
public void GetBusyLevel() { int busylevel; DayOfWeek day = DateTime.Now.DayOfWeek; switch (day) { case DayOfWeek.Sunday: busylevel = 1; break; case DayOfWeek.Monday: busylevel = 5; break; case DayOfWeek.Tuesday: busylevel = 5; break; case DayOfWeek.Wednesday: busylevel = 4; break; case DayOfWeek.Thursday: busylevel = 4; break; case DayOfWeek.Friday: busylevel = 3; break; case DayOfWeek.Saturday: busylevel = 2; break; default: busylevel = -1; break; } }
No comments:
Post a Comment