Why would someone use the << operator in an enum declaration?

前端 未结 7 718
悲&欢浪女
悲&欢浪女 2020-12-29 19:13

I was looking at the code I have currently in my project and found something like this:

public enum MyEnum
{
    open     = 1 << 00,
    close    = 1 &         


        
7条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 19:23

    It's just meant to be a cleaner / more intuitive way of writing the bits. 1, 2, 3 is a more human-readable sequence than 0x1, 0x2, 0x4, etc.

提交回复
热议问题