Consider Below Code, how to let Console.WriteLine(Colors.All) output "Red, Yellow, Blue,Green", instead of "All"?
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Colors.All);// All
var noRed = Colors.All & ~Colors.Red;
Console.WriteLine(noRed);// Yellow, Blue, Green
Console.ReadLine();
}
}
[Flags]
enum Colors
{
None=0,
Red= 1<<0,
Yellow = 1<<1,
Blue= 1<<2,
Green=1<<3,
All = Red | Yellow| Blue | Green
}
}