What will be displayed on the console?
 
using System;

 [Flags] 
public enum Organs: byte 
{ 
    None = 0x00, 
    Heart = 0x01, 
    Lung = 0x02, 
    Liver = 0x04 
} 
public class App 
{ 
      public static void Main(string[] args) 
      { 

          Organs organs = Organs.Lung | Organs.Heart; 
          Console.WriteLine(organs); 
      } 
}
 
Explanation
Correct answer: Heart, Lung because attribute Flags changes behavior of enum; without this attribute 3 will be displayed.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C# quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes