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

前端 未结 7 634
悲&欢浪女
悲&欢浪女 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:45

    To avoid typing out the values for a Flags enum by hand.

    public enum MyEnum
    {
        open     = 0x01,
        close    = 0x02,
        Maybe    = 0x04,
        ........
    }
    
    0 讨论(0)
提交回复
热议问题