Switch / Select Case Assistant for Enums

Top  Previous  Next

 C#   VB.NET   VB6   VBA 

The Switch / Select Case Assistant for Enums feature allows you to quickly create the block of case statements for an enum expression.

MZ-Tools offers the following ways to show the Switch / Select Case Assistant for Enums:

  • The MZ-Tools | Switch / Select Case Assistant for Enums... menu.
  • The Switch / Select Case Assistant for Enums... menu entry on the context menu of a code window.
  • The Switch / Select Case Assistant for Enums button on the MZ-Tools - Main toolbar.
  • In Visual Studio 2015 and higher, the keyboard shortcut associated with the MZTools.SwitchOrSelectCaseAssistant command.
  • In Visual Studio 2013 and lower, the keyboard shortcut associated with the MZTools8.SwitchOrSelectCaseAssistant command.
  • In VB6 / VBA, the keyboard shortcut associated with the Select Case Assistant for Enums feature.

When you type a statement such as:

[C#]

 

switch (dayOfWeek)

[VB.NET / VB / VBA]

 

Select Case dayOfWeek

and you invoke this assistant the following window is shown:

SelectCaseAssistant

In this window, you can choose the values of the enum expression which require a separate case statement. If you leave enum values not selected, a default (C#) or Case Else (VB.NET / VB / VBA) statement is added.

You can also select if you want to use full names for the enum values or not, and the order of the case statements.

Optionally you can even compose a template to be used for each individual case statement. Such template can include predefined variables such as the name of the enum item or parent enum (with normal case, upper case, underscores, etc.).

Remarks:

  • There are some limitations to the expressions that MZ-Tools can resolve in order to get the returned type.

See Also:

Keyboard Shortcuts Options