Kevin McNeish Blog

All things iOS, Kindle and .NET

Recent Posts

Tags

News

  • First books in my new book series, "iOS App Development for Non-Programmers" are now available! iBookStore: http://itunes.apple.com/us/book/book-1-diving-in-ios-app-development/id558788074?mt=11 Amazon: http://www.amazon.com/dp/B0097N8XBE Amazon: http://www.amazon.com/dp/B0099RQGMQ

Community

Email Notifications

Archives

Converting a String to an Enumerated Value

You can convert a string to an enumerated value by using Enum.Parse(). For example, the following code converts the string "Int32" to the corresponding System.Data.DbType enum value:
Param.DbType = (DbType)Enum.Parse(typeof(DbType), "Int32", true);
This is a nice tip that will save you from writing some ugly code!
Leave a Comment

(required) 

(required) 

(optional)
 

(required) 

If you can't read this number refresh your screen
Enter the numbers above: