سؤال

My application defines several enums that include the [Flags] attribute.

I wanted to write a small utility method to check if a flag was set for any of those enums and I came up with the following.

protected static bool IsFlagSet<T>(ref T value, ref T flags)
{
    return ((value & flags) == flags);
}

But this gives me the error "Operator '&' cannot be applied to operands of type 'T' and 'T'".

Can this be made to work?

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top