How to bitwise shift in VB.NET?

Deadly 提交于 2019-12-04 03:01:47

问题


How do I bitwise shift right/left in VB.NET? Does it even have operators for this, or do I have to use some utility method?


回答1:


VB.NET has had bit shift operators (<< and >>) since 2003.




回答2:


You can use the << and >> operators, and you have to specify how many bits to shift.

myFinal = myInteger << 4   ' Shift LEFT by 4 bits.
myFinal = myInteger >> 4   ' Shift RIGHT by 4 bits.

You can also use it as a unary operator...

myFinal <<= 4     ' Shift myFinal LEFT by 4 bits, storing the result in myFinal.
myFinal >>= 4     ' Shift myFinal RIGHT by 4 bits, storing the result in myFinal.


来源:https://stackoverflow.com/questions/1417645/how-to-bitwise-shift-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!