您似乎真正想要的是旋转位,而不是移动它们:
Module Module1
Function RORUInt16(n As UInt16, r As Integer) As UInt16
' ensure number of places to shift is valid
r = r And 15
If r = 0 Then
' nothing to do
Return n
End If
' get bits from RHS
Dim RHS = Convert.ToUInt16(n And ((2 << r) - 1))
' shift the original bits right (loses the RHS saved previously)
Dim rb = Convert.ToUInt16(n >> r)
' put back the lost bits on the LHS
rb = Convert.ToUInt16(rb Or (RHS << (16 - r)))
Return rb
End Function
Sub Main()
Dim b1 As UInt16 = Convert.ToUInt16("0000001000000111", 2)
Console.WriteLine(Convert.ToString(b1, 2).PadLeft(16, "0"c))
Console.WriteLine(Convert.ToString(RORUInt16(b1, 1), 2).PadLeft(16, "0"c))
Console.ReadLine()
End Sub
End Module