Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Enum To Method
Message
De
17/03/2010 12:45:21
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01455109
Message ID:
01455119
Vues:
30
>>>I created a Web Control. In it is this enum:
>>>
>>>
>>>public enum PageMode
>>>{
>>>    New,
>>>    Edit,
>>>    View
>>>}
>>>
>>>
>>>From outside the control I'm trying to do:
>>>
>>>
>>>crlRoles.SetPageMode(crlRoles.PageMode.Edit);
>>>
>>>
>>>I'm getting a compile error "'PageMode': cannot reference a type through an expression; try 'crlRoles.PageMode' instead".
>>>
>>>How do I do this in an ASP.Net app?
>>
>>I generally find it better not to place enums inside of classes unless you only plan on using it within the class. That doesn't seem to be the case here, so why not put the enum in its own file and move it outside the class. In web apps I have a folder called Enums and I put them all in there where they are used in the web pages.
>>Tim
>
>In a stand-alone CS file?

Yes, it does not need to be in a class. Much easier to make it accessible for those type situations.
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform