Enum.HasFlag, why no Enum.SetFlag?

前端 未结 8 2120
别跟我提以往
别跟我提以往 2020-12-24 05:38

I have to build an extension method for each flag type I declare, like so:

public static EventMessageScope SetFlag(this EventMessageScope flags, 
    EventMe         


        
8条回答
  •  情书的邮戳
    2020-12-24 06:29

    The reason I'm finding is that since enum is a value type, you cannot pass it in and set its type. To all of you that think its stupid, I say this to you: Not all developers understand bit flags and how to turn them on or off (which is much less intuitive).

    Not a stupid idea, just not possible.

提交回复
热议问题