PC Review


Reply
Thread Tools Rate Thread

Converting enum Keys value to string

 
 
Ahmed
Guest
Posts: n/a
 
      14th Apr 2005
I am saving the enum value of specific keys to an xml file which i then
need to get the string representation. I believe KeysConverter is there
for that but i have trouble using it for my purpose.
i want to give it a value and have it spit out its Keys equivilancy for
example.

121 -> Keys.F10

I am not sure if i am playing with the right function or not but any
advise or suggestions would be appreciated

 
Reply With Quote
 
 
 
 
Rob Lans
Guest
Posts: n/a
 
      14th Apr 2005
For enum to int conversion use a cast:

int i = (int)Keys.F10;
Keys k = (Keys)i;

For enum to string conversion:

string s = Keys.F10.ToString();
Keys k = (Keys)Enum.Parse(typeof(Keys), s);


Rob.

"Ahmed" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am saving the enum value of specific keys to an xml file which i then
> need to get the string representation. I believe KeysConverter is there
> for that but i have trouble using it for my purpose.
> i want to give it a value and have it spit out its Keys equivilancy for
> example.
>
> 121 -> Keys.F10
>
> I am not sure if i am playing with the right function or not but any
> advise or suggestions would be appreciated
>



 
Reply With Quote
 
Ahmed
Guest
Posts: n/a
 
      15th Apr 2005
Beautiful, thats exctly what i am looking for!

thx

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting string to enum member!!! Harald Microsoft C# .NET 4 15th Aug 2007 07:51 AM
converting string in enum !!! Harald Microsoft VC .NET 2 14th Aug 2007 04:18 PM
Converting String to Enum Value =?Utf-8?B?Um9iZXJ0IFcu?= Microsoft C# .NET 2 22nd Oct 2005 08:49 PM
Converting string to Keys enum value? Arkion Microsoft Dot NET Framework 1 9th Sep 2004 05:46 PM
Converting string or int to an Enum Ozzy Knox Microsoft C# .NET 3 16th Jul 2003 06:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:36 AM.