mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-24 14:06:10 +00:00
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:
committed by
Wouter van Oortmerssen
parent
557c57eb9d
commit
e3b432cba8
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user