Enums use native enums in C#

Enums should not be (badly) emulated with classes in C# but should
use native C# enums instead. Java implementation made an explicit
choice not to use the (more complex) Java enums, but C# enums are
just light-weight syntactic coating over integral types.

Fixes issue #171.

Change-Id: I9f4d6ba5324400a1e52982e49b58603cb7d7cca7
This commit is contained in:
Mormegil
2015-04-13 13:25:03 +02:00
committed by Wouter van Oortmerssen
parent 557c57eb9d
commit e3b432cba8
6 changed files with 129 additions and 91 deletions

View File

@@ -3,16 +3,11 @@
namespace MyGame.Example
{
public sealed class Color
public enum Color : sbyte
{
private Color() { }
public static readonly sbyte Red = 1;
public static readonly sbyte Green = 2;
public static readonly sbyte Blue = 8;
private static readonly string[] names = { "Red", "Green", "", "", "", "", "", "Blue", };
public static string Name(int e) { return names[e - Red]; }
Red = 1,
Green = 2,
Blue = 8,
};