使用C#如何表达VBA"select case control.ID"

Using C# how to express VBA "select case control.ID"

在VBA中,我使用下面的代码来控制功能区xml,

Sub paragraphs_style(ByVal control As IRibbonControl)    
Select Case control.ID
        Case "article_type" 
           xxxxxx
End Select
end sub

但是在c#中,如何表达呢?

您需要使用 switch statement:

switch (control.ID)
{
   case "article_type":
       // executable code
       break;
   case "something else":
       //
       break;
   case "A":
   case "B":
       // here, flow falls through, equivalent to Case "A","B" in VBA
       break;
   default:
       // equivalent to Case Else in VBA.
       break;
}