Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2005

Tip: Looking for answers? Try searching our database.

Converting enum Keys value to string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ahmed - 14 Apr 2005 09:37 GMT
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 :)
Rob Lans - 14 Apr 2005 13:30 GMT
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.

>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
[quoted text clipped - 6 lines]
> I am not sure if i am playing with the right function or not but any
> advise or suggestions would be appreciated :)
Ahmed - 15 Apr 2005 06:47 GMT
Beautiful, thats exctly what i am looking for!

thx

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.