RE: passing enum value as an argument



Madestro <me_no_like_spam_juanDOTromero@bowneDOTcom> wrote:
> That would defeat the purpose of having an Enum. you might as well create
> three variables then.

I don't see how it would defeat type safety, which is the purpose of
having an enum from my point of view. So long as you couldn't pass in a
value from a *different* enum, it would be fine. I don't see any reason
why the language couldn't allow it.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: passing enum value as an argument
    ... Do you actually write much code without option strict on? ... about type safety. ... > You seem to think that the sole purpose of enums is to force the ... For you to get the benefits of an Enum, ...
    (microsoft.public.dotnet.general)
  • RE: passing enum value as an argument
    ... But it *doesn't* defeat the purpose. ... It doesn't stop the compiler from ... noticing if he's trying to pass in a value which isn't in the enum. ...
    (microsoft.public.dotnet.general)
  • Re: Enums Type Question
    ... The purpose was to abstract the name the programmer would see when choosing ... would represent the real css class to be applied to the control when the ... well as the enum value. ... public void message(string msgStr, messageType msgType) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Stupid Compiler Question or Compiler Stupid Question
    ... I don't understand the purpose of the:type syntax on an enum. ... >> requiring a cast. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Stupid Compiler Question or Compiler Stupid Question
    ... Bill wrote: ... I don't understand the purpose of the:type syntax on an ... type syntax is effectively to say how it should be ... that there is an implicit conversion between the enum and that type, ...
    (microsoft.public.dotnet.languages.csharp)