Enum Has Any Flags - CSharp System

CSharp examples for System:Enum

Description

Enum Has Any Flags

Demo Code


using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Globalization;
using System;/*from   w ww  .j av a 2 s.c om*/

public class Main{
  public static bool HasAnyFlags<T>(this Enum type, T value)
  {
    try
    {
      return (((int)(object)type & (int)(object)value) > 0);
    }
    catch
    {
      return false;
    }
  }
}

Related Tutorials