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

问题描述 投票:1回答:1

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

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

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

c# ms-word vsto
1个回答
1
投票

你需要使用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;
}
© www.soinside.com 2019 - 2024. All rights reserved.