What is the 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
flags = flags Or MyEnum.SomeFlag
http://msdn.microsoft.com/zh-CN/library/wz3k228a(VS.80).aspx
Not that this is any sort of official source, but check out these pages:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.