Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要对 16 位整数(ushort / UInt16)执行按位左移,但 C# 中的按位运算符似乎仅适用于 int(32 位)。如何在 ushort 上使用 <<,或者至少通过简单的解决方法获得相同的结果?
移位后将结果值转换回 ushort:
ushort value = 1; ushort shifted = (ushort)(value << 2);