开发者

What is the equivalent of |= in Visual Basic?

开发者 https://www.devze.com 2023-01-21 14:22 出处:网络
What is the开发者_如何学Python equivalent of the |= operator in Visual Basic? For example (C#):

What is the开发者_如何学Python equivalent of the |= operator in Visual Basic? For example (C#):

flags |= MyEnum.SomeFlag


flags = flags Or MyEnum.SomeFlag


In C#, |= is the Or assignment operator.

There's no equivalent operator in VB.

See the list of Assignment Operators (Visual Basic).


Visual Basic does not support compound assignment operators as shown in the C# sample. You'll need to use the expanded form of the assignment and the vb version of the bitwise or operator (simple Or)

flags = flags Or MyEnum.SomeFlag


Not that this is any sort of official source, but check out these pages:

  • http://www.aspfree.com/c/a/VB.NET/Operators/2/
  • http://www.aspfree.com/c/a/VB.NET/Operators/3/

It seems to me that there isn't an existing combination of the bitwise-or-plus-assignment operator in VB.NET. But there is a bitwise-or operator, and an assignment operator, which you can combine manually:

flags = flags Or MyEnum.SomeFlag


flags = flags Or MyEnum.SomeFlag

http://msdn.microsoft.com/en-us/library/wz3k228a(VS.80).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消