diff options
Diffstat (limited to 'Examples/csharp')
-rw-r--r-- | Examples/csharp/enum/example.h | 2 | ||||
-rw-r--r-- | Examples/csharp/enum/runme.cs | 25 |
2 files changed, 13 insertions, 14 deletions
diff --git a/Examples/csharp/enum/example.h b/Examples/csharp/enum/example.h index 525d62afc..9119cd9fc 100644 --- a/Examples/csharp/enum/example.h +++ b/Examples/csharp/enum/example.h @@ -5,7 +5,7 @@ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } - enum speed { IMPULSE, WARP, LUDICROUS }; + enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; void enum_test(speed s); }; diff --git a/Examples/csharp/enum/runme.cs b/Examples/csharp/enum/runme.cs index 3db11b69b..42ba896a2 100644 --- a/Examples/csharp/enum/runme.cs +++ b/Examples/csharp/enum/runme.cs @@ -6,27 +6,26 @@ public class runme { // Print out the value of some enums Console.WriteLine("*** color ***"); - Console.WriteLine(" RED = " + example.RED); - Console.WriteLine(" BLUE = " + example.BLUE); - Console.WriteLine(" GREEN = " + example.GREEN); + Console.WriteLine(" " + color.RED + " = " + (int)color.RED); + Console.WriteLine(" " + color.BLUE + " = " + (int)color.BLUE); + Console.WriteLine(" " + color.GREEN + " = " + (int)color.GREEN); Console.WriteLine("\n*** Foo::speed ***"); - Console.WriteLine(" Foo::IMPULSE = " + Foo.IMPULSE); - Console.WriteLine(" Foo::WARP = " + Foo.WARP); - Console.WriteLine(" Foo::LUDICROUS = " + Foo.LUDICROUS); + Console.WriteLine(" Foo::" + Foo.speed.IMPULSE + " = " + (int)Foo.speed.IMPULSE); + Console.WriteLine(" Foo::" + Foo.speed.WARP + " = " + (int)Foo.speed.WARP); + Console.WriteLine(" Foo::" + Foo.speed.LUDICROUS + " = " + (int)Foo.speed.LUDICROUS); Console.WriteLine("\nTesting use of enums with functions\n"); - example.enum_test(example.RED, Foo.IMPULSE); - example.enum_test(example.BLUE, Foo.WARP); - example.enum_test(example.GREEN, Foo.LUDICROUS); - example.enum_test(1234,5678); + example.enum_test(color.RED, Foo.speed.IMPULSE); + example.enum_test(color.BLUE, Foo.speed.WARP); + example.enum_test(color.GREEN, Foo.speed.LUDICROUS); Console.WriteLine( "\nTesting use of enum with class method" ); Foo f = new Foo(); - f.enum_test(Foo.IMPULSE); - f.enum_test(Foo.WARP); - f.enum_test(Foo.LUDICROUS); + f.enum_test(Foo.speed.IMPULSE); + f.enum_test(Foo.speed.WARP); + f.enum_test(Foo.speed.LUDICROUS); } } |