C# Flags Attribute for multiple enums

    0

    0

    Konrad Psiuk

    The following code uses the Flags attribute to identify the type of integer that is being manipulated. The int type is used because it is the most primitive data type in the C# language.

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Threading.Tasks.Dataflow; namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { var e = EEE.five; Console.WriteLine((e & EEE.five)==EEE.four); //false Console.WriteLine(Convert.

    namespace ConsoleApp1
    {
      internal class Program
      {
        static void Main(string[] args)
        {
          var e = EEE.five;
          Console.WriteLine((e & EEE.five)==EEE.four); //false
        }
      }
    
      [Flags]
      enum EEE
      {
        one = 0,
        two = 1,
        three = 1 << 1,
        four = 1 << 2,
        five = 1 << 3
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.