1

我想了解如何在 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 。

4

2 回答 2

4

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

VB.NET     C#
--------   --
And        &
AndAlso    &&
Or         |
OrElse     ||
Xor        ^
Mod        %
Not        !
于 2013-09-19T13:04:20.523 回答
4

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

vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled

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

于 2013-09-19T13:00:47.077 回答