PC Review


Reply
Thread Tools Rate Thread

Converting strings to enums

 
 
=?Utf-8?B?TWljaGFsIFJpemVr?=
Guest
Posts: n/a
 
      19th Nov 2004
Hi,
I have a simple question:
When i get string value for enum type can i convert it somehow back to enum
type?
I would like to do something like this....
string str = System.Windows.Keys.Up.ToString();
....
System.Windows.Forms.Keys val = str;
 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      19th Nov 2004
You can do it with a little Reflection - there is an implementation of the
Enum.Parse method in the OpenNETCF.EnumEx class:-
http://www.opennetcf.org/library/Ope...overloads.html

This is part of the Smart Device Framework (www.opennetcf.org/sdf/) and you
can find the source online on the website too.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

"Michal Rizek" <(E-Mail Removed)> wrote in message
news:9F5E0EA5-B561-45D8-B81C-(E-Mail Removed)...
> Hi,
> I have a simple question:
> When i get string value for enum type can i convert it somehow back to
> enum
> type?
> I would like to do something like this....
> string str = System.Windows.Keys.Up.ToString();
> ...
> System.Windows.Forms.Keys val = str;



 
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 Enums (c#) Mark Olbert Microsoft Dot NET Framework 2 25th Jan 2006 01:13 AM
Strings ints and enums Jeremy Microsoft VC .NET 6 15th Jul 2005 06:17 PM
Converting Strings into Manus =?Utf-8?B?QUJC?= Microsoft VB .NET 1 23rd Mar 2005 01:41 PM
PN: Converting C Strings to managed strings Peter Nolan Microsoft VC .NET 0 20th Nov 2003 11:01 PM
converting strings to decimal Paul K Microsoft C# .NET 7 18th Nov 2003 01:37 AM


Features
 

Advertising
 

Newsgroups
 


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