CSharp examples for System:Enum
Sets the Enum flag off in the specified mask.
using System.Threading; using System.Reflection; using System.ComponentModel; using System.Collections.Generic; using System;//from w ww .j av a2s. co m public class Main{ /// <summary> /// Sets the flag off in the specified mask. /// </summary> /// <typeparam name="T">The flag type.</typeparam> /// <param name="mask">The mask to set flag off.</param> /// <param name="flag">The flag to set.</param> /// <returns>The mask with the flag set to off.</returns> public static T SetFlagOff<T>(this Enum mask, T flag) where T : struct, IComparable, IFormattable, IConvertible { ulong flagInt = Convert.ToUInt64(flag); ulong maskInt = Convert.ToUInt64(mask); maskInt &= ~flagInt; return ConvertFlag<T>(maskInt); } }