Set Enum Flags - CSharp System

CSharp examples for System:Enum

Description

Set Enum Flags

Demo Code


using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Globalization;
using System;/*from www . ja  v a2 s.c o m*/

public class Main{
        public static T SetFlags<T>(this Enum current, T setflags, bool onoff)
  {
    return (onoff ? (T)(object)(((int)(object)current | (int)(object)setflags)) : (T)(object)(((int)(object)current & ~(int)(object)setflags)));
  }
}

Related Tutorials