#include "stdafx.h"
using namespace System;
[ Flags ]
enum class Color
{
Red = 1,
Blue = 2,
Green = 4 // use powers of 2
};
int main()
{
Console::WriteLine("Colors: {0}, {1}, {2}", Color::Red, Color::Blue,Color::Green);
Console::WriteLine("Colors: {0:d}, {1:d}, {2:d}", Color::Red, Color::Blue,Color::Green);
Color c = Color::Red | Color::Blue;
String^ s1 = c.ToString("X");
Console::WriteLine( s1 );
String^ s2 = Enum::Format( Color::typeid, c , "G");
Console::WriteLine(s2 );
}
|