What do two left-angle brackets “<<” mean in C#?

前端 未结 15 2014
长情又很酷
长情又很酷 2020-12-12 13:55

Basically the questions in the title. I\'m looking at the MVC 2 source code:

[Flags]
public enum HttpVerbs {
    Get = 1 << 0,
    Post = 1 << 1,         


        
15条回答
  •  爱一瞬间的悲伤
    2020-12-12 14:06

    It is implied in a number of answers but never stated directly...

    For every position that you shift a binary number left, you double the original value of the number.

    For example,

    Decimal 5 binary shifted left by one is decimal 10, or decimal 5 doubled.

    Decimal 5 binary shifted left by 3 is decimal 40, or decimal 5 doubled 3 times.

提交回复
热议问题