Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using enum as a parameter
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00971423
Message ID:
00971493
Views:
17
I guess it will work with 0, probably because 0 is the default value for all enum types. But it will not work with any other value.

>Stephane,
>That is what I expected also, but I wrote a little console app to ilustrate that my expectations were not met:
>
>using System;
>
>namespace test
>{
>	class Class1
>	{
>		[STAThread]
>		static void Main(string[] args)
>		{
>			Console.WriteLine("Start of app");
>			test.Class1.myMethod(test.Class1.myEnum.SR0);
>			test.Class1.myMethod(0);
>			System.Threading.Thread.Sleep(5000);
>		}
>		public enum myEnum : byte
>		{
>			SR0		= 0xE0,
>			SR1		= 0xE1,
>			SR2		= 0xE2,
>			SR3		= 0xE3
>		}
>		public static void myMethod (myEnum paraMyEnum)
>		{
>			Console.WriteLine(((byte) paraMyEnum).ToString());
>		}
>	}
>}
>
>
>Output will be:
>
>Start of app
>224
>0
>
>(note 224 is equal to 0xE0)
>
>
>
>
>
>>Humm.., I don't beleive you can pass anything else but a myEnum type to myMethod...
>>
>>Do you have an sample code that works passing something else then a myEnum type ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform