Search code examples
c#javabitwise-operators

Equivalent of Java triple shift operator (>>>) in C#?


What is the equivalent (in C#) of Java's >>> operator?

(Just to clarify, I'm not referring to the >> and << operators.)


Solution

  • Edit: The Unsigned right-shift operator >>> is now also available in C# 11 and later.

    For earlier C# versions, you can use unsigned integer types, and then the << and >> do what you expect. The MSDN documentation on shift operators gives you the details.

    Since Java doesn't support unsigned integers (apart from char), this additional operator became necessary.