What does the “>>” operator in C# do?

前端 未结 5 443
借酒劲吻你
借酒劲吻你 2020-12-11 17:10

I ran into this statement in a piece of code:

Int32 medianIndex = colorList.Count >> 1;

colorList is a list of class

5条回答
  •  情书的邮戳
    2020-12-11 17:55

    It's a bitwise opperator a definition i just grabbed from http://en.wikibooks.org/wiki/C_Sharp_Programming/Operators:

    The binary operator >> evaluates its operands and returns the resulting first argument right-shifted by the number of bits specified by the second argument. It discards low-order bits that are shifted beyond the size of its first argument and sets new high-order bits to the sign bit of the first argument, or to zero if the first argument is unsigned.

    Its basically dividing by 2...

提交回复
热议问题