Has Any Flag from Enum - CSharp System

CSharp examples for System:Enum

Description

Has Any Flag from Enum

Demo Code


using System.Text;
using System.IO;/*from w ww .  j  av a2  s  . c o m*/
using System.Globalization;
using System.Collections.Generic;
using System;

public class Main{
        public static bool HasAnyFlag(this Enum value, Enum toTest)
        {
            var val = ((IConvertible)value).ToUInt64(null);
            var test = ((IConvertible)toTest).ToUInt64(null);

            return (val & test) != 0;
        }
}

Related Tutorials