Enumeration Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yosh

    Enumeration Question

    Hi!

    I am curious if it's possible to get the actual string name representation
    of an Enum type. I want the actual Enum name that represents the number and
    place it in a string.

    public enum SecurityTypeEnu m

    {

    AppConfig = 1,

    NTSecurity = 2

    }




  • Tom Porterfield

    #2
    Re: Enumeration Question

    On Fri, 22 Apr 2005 18:25:15 -0500, Yosh wrote:
    [color=blue]
    > Hi!
    >
    > I am curious if it's possible to get the actual string name representation
    > of an Enum type. I want the actual Enum name that represents the number and
    > place it in a string.
    >
    > public enum SecurityTypeEnu m
    >
    > {
    >
    > AppConfig = 1,
    >
    > NTSecurity = 2
    >
    > }[/color]

    SecurityTypeEnu m.AppConfig.ToS tring() = "AppConfig"
    SecurityTypeEnu m.NTSecurity.To String() = "NTSecurity "

    Is that what you mean? Just call ToString on it and it will give you the
    string name.
    --
    Tom Porterfield

    Comment

    • Tim Wilson

      #3
      Re: Enumeration Question

      See the static GetName (or GetNames) method of the Enum class.

      --
      Tim Wilson
      ..Net Compact Framework MVP

      "Yosh" <Yosh@nospam.co m> wrote in message
      news:%23maFLK5R FHA.1564@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > Hi!
      >
      > I am curious if it's possible to get the actual string name representation
      > of an Enum type. I want the actual Enum name that represents the number[/color]
      and[color=blue]
      > place it in a string.
      >
      > public enum SecurityTypeEnu m
      >
      > {
      >
      > AppConfig = 1,
      >
      > NTSecurity = 2
      >
      > }
      >
      >
      >
      >[/color]


      Comment

      Working...