The requested page is not available for the requested platform. You are viewing the content for Default platform.

Add Default Case Branch

Adds the default case branch to the current switch statement.

Availability

From the context menus or via shortcuts:

  • when the edit cursor or caret is on a switch statement, provided that this switch statement does not cover all available cases.

Example

switch (DateTime.Now.DayOfWeek)
{
  case DayOfWeek.Monday:
    TodaySchedule = MonSchedule;
    break;
  case DayOfWeek.Tuesday:
    TodaySchedule = TueSchedule;
    break;
  case DayOfWeek.Wednesday:
    TodaySchedule = WedSchedule;
    break;
  case DayOfWeek.Thursday:
    TodaySchedule = ThuSchedule;
    break;
  case DayOfWeek.Friday:
    TodaySchedule = FriSchedule;
    break;
}
Select Case DateTime.Now.DayOfWeek
  Case DayOfWeek.Monday
    TodaySchedule = MonSchedule

  Case DayOfWeek.Tuesday
    TodaySchedule = TueSchedule

  Case DayOfWeek.Wednesday
    TodaySchedule = WedSchedule

  Case DayOfWeek.Thursday
    TodaySchedule = ThuSchedule

  Case DayOfWeek.Friday
    TodaySchedule = FriSchedule
End Select

Result:

switch (DateTime.Now.DayOfWeek)
{
  case DayOfWeek.Monday:
    TodaySchedule = MonSchedule;
    break;
  case DayOfWeek.Tuesday:
    TodaySchedule = TueSchedule;
    break;
  case DayOfWeek.Wednesday:
    TodaySchedule = WedSchedule;
    break;
  case DayOfWeek.Thursday:
    TodaySchedule = ThuSchedule;
    break;
  case DayOfWeek.Friday:
    TodaySchedule = FriSchedule;
    break;
  default:
    break;
}
Select Case DateTime.Now.DayOfWeek
  Case DayOfWeek.Monday
    TodaySchedule = MonSchedule

  Case DayOfWeek.Tuesday
    TodaySchedule = TueSchedule

  Case DayOfWeek.Wednesday
    TodaySchedule = WedSchedule

  Case DayOfWeek.Thursday
    TodaySchedule = ThuSchedule

  Case DayOfWeek.Friday
    TodaySchedule = FriSchedule

  Case Else
End Select