C#中逻辑右移的代码是什么?

What is code for logical right shift in C#?

我正在尝试将具有逻辑右移 (>>>) (Difference between >>> and >>) 的 Java 代码翻译成 C#

Java代码为

 return hash >>> 24 ^ hash & 0xFFFFFF;

C# 被标记为 >>> 语法错误。

如何解决?

更新 1 人们建议在 C# 中使用 >>,但它没有解决问题。

System.out.println("hash 1 !!! = " + (-986417464>>>24));

是197

但是

Console.WriteLine("hash 1 !!! = " + (-986417464 >> 24));

是-59

谢谢!

对于 C#,您可以只使用 >>

If the left-hand operand is of type uint or ulong, the right-shift operator performs a logical shift: the high-order empty bit positions are always set to zero.

来自docs.

Java 需要引入 >>> 因为它唯一的无符号类型是 char,它的操作是用整数完成的。

另一方面,C# 有无符号类型,它执行右移而不带符号扩展:

uint h = (uint)hash;
return h >> 24 ^ h & 0xFFFFFF;