mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-19 07:53:04 +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,15 +3,10 @@
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
public sealed class Any
|
||||
public enum Any : byte
|
||||
{
|
||||
private Any() { }
|
||||
public static readonly byte NONE = 0;
|
||||
public static readonly byte Monster = 1;
|
||||
|
||||
private static readonly string[] names = { "NONE", "Monster", };
|
||||
|
||||
public static string Name(int e) { return names[e]; }
|
||||
NONE = 0,
|
||||
Monster = 1,
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user