Re: Smart way to connect enums to string values

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Henke (henke_nord_at_hotmail.com)
Date: 10/12/04


Date: Tue, 12 Oct 2004 15:59:11 +0200

Yeh, that's ok as long as you want the same string as your enum-name. But
since I'm from sweden and code in english but want's my displayed enum
strings in swedish I can't do it that way.

Any other good ideas?
/Henke

"©tefan ©imek" <simek.blah@kascomp.blah.sk> skrev i meddelandet
news:ud8vHHGsEHA.3712@TK2MSFTNGP15.phx.gbl...
>
> "Henke" <henke_nord@hotmail.com> wrote in message
> news:e4i7HBGsEHA.3980@TK2MSFTNGP12.phx.gbl...
>> Hi!
>> Has anyone a nice way to connect a enum to a string value.
>> Now I declare a const string [] in the same class as my enum is defined.
>> But I doubt that's the "object oriented" way of doing it.
>> Any better suggestions?
>>
>> Thanks in advance?
>> /Henke
>>
>
> I don't know if I understand your question well, but you might like to
> have a look at the
> Enum.ToString() and Enum.Parse() functions, like:
>
> enum Test { One, Two, Three };
>
> public static void Main(string[] args)
> {
> Test tst = Test.One;
> string str = tst.ToString();
> Test tst2 = (Test) Enum.Parse(typeof(Test), str);
>
> Console.WriteLine("tst = {0}\nstr = {1}\ntst2 = {2}", tst, str, tst2);
> }
>
> HTH,
> Stefan
>



Relevant Pages

  • Re: DBDATE / DBMONEY in SQL =?ISO-8859-1?Q?=E4ndern?= ??
    ... [Note that this list is usually in English. ... You can then transfer the data to the target table and ... Dates and datetimes have their own storage format which is independent of any ... You have several options to format string representation of dates, ...
    (comp.databases.informix)
  • Re: And so we come to SA vs England...
    ... dramatic elements. ... And it was a 2nd string SA side. ... That try that Vd Linde scored against the English - never in your life ...
    (rec.sport.rugby.union)
  • Re: Could not convert variant of type (Null) into type (String)
    ... My English is pretty bad too... ... -If you are setting a field in you SQL database which is requiring a string ... Working through these issues I found it useful to watch the database ...
    (borland.public.delphi.database.ado)
  • Re: Substituting the main menu bar(s)
    ... The tooltip/Menu text string is only one string, which is delimited by '\n', ... language but if worst comes to worst in the default hardcoded language. ... like everything to be in English, partly because my user guide is in ... But you could get around this by having two dictionaries ...
    (microsoft.public.vc.mfc)
  • Character encodings
    ... I'm looking for an easy way to remove french characters and replace them ... with their english equivalent. ... French String: Jôêl ... English String: J??l ...
    (comp.lang.java.help)