Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using enum as a parameter
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00971423
Message ID:
00971493
Vues:
16
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 ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform