左移位运算符的问题
< < 在C#中是左移位运算符
在VB.NET中有左移位运算符吗?如果沒有如何实现按位左移的功能
[解决办法]
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim b As Byte = 1
MsgBox(Convert.ToInt32(b))
b = b < < 1
MsgBox(Convert.ToInt32(b))
End Sub
[解决办法]
Dim Pattern As Short = 192 ' Bit pattern is 0000 0000 1100 0000.
Dim Result1, Result2, Result3, Result4, Result5 As Short
Result1 = Pattern < < 0 ' Result is 192 (0000 0000 1100 0000).
Result2 = Pattern < < 4 ' Result is 3072 (0000 1100 0000 0000).
Result3 = Pattern < < 9 ' Result is -32768 (1000 0000 0000 0000).
Result4 = Pattern < < 17 ' Result is 384 (0000 0001 1000 0000).
Result5 = Pattern < < -1 ' Result is 0 (shifted 15 places to left).
---------------msdn
[解决办法]
b = b < < 1
没有错吧
[解决办法]
不行的话左移乘2的几次方,移多少次方多少,右移整除2的几次方
如
b = b < <1 可写成 b = b * Math.Pow(2, 1)就行了