如何在 VB.NET 中按位移位?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1417645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 14:25:33 来源:igfitidea点击:
How to bitwise shift in VB.NET?
提问by TheFlash
回答by Mehrdad Afshari
回答by TheFlash
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.