Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Enum To Method
Message
 
À
17/03/2010 12:54:32
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01455109
Message ID:
01455137
Vues:
29
>>>>>>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.
>>Where else can you put them?
>

>>It all depends on what you are using them for. I will rarely ever put them inside a class but you can if it is only being used inside >>that class it might make sense. Since you can put them in a cs file all by itself which is what I do you could also create a cs file >>called Enums.cs and put all of them in the same file. I create Enums for lots of things because they help to prevent mistyping for >>yourself.

That's eactly what I did. I also moved my Event Args and Delgates this way also, because the same events are used in multiple controls.

Good info. Thanks


>
>I also create compoonents that I expose to other applications. I use enums so they can only provide me specific parameters when using methods.
>Tim
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform