vb.net中Or命令的等效代码

时间:2013-09-19 12:59:33

标签: c# vb.net

我想学习如何在C#中使用Or命令(VB.NET)?

我有一个例子:

foundCommand = _applicationObject.Commands.AddNamedCommand(_addInInstance, name, name, caption, _
                                True, iconID, Nothing, vsCommandStatus.vsCommandStatusSupported Or vsCommandStatus.vsCommandStatusEnabled)

我想在C#中一起使用vsCommandStatus.vsCommandStatusNotSupported或vsCommandStatus.vsCommandStatusEnabled。

2 个答案:

答案 0 :(得分:4)

使用按位OR运算符|链接枚举标志值,这是您的情况。

vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled

对于条件或布尔值,请使用逻辑OR运算符||

答案 1 :(得分:4)

这是一个VB.NET到C#运算符的小表:

VB.NET     C#
--------   --
And        &
AndAlso    &&
Or         |
OrElse     ||
Xor        ^
Mod        %
Not        !
相关问题