How to convert string to any type

Posted by DJPB on Stack Overflow See other posts from Stack Overflow or by DJPB
Published on 2010-05-27T16:18:29Z Indexed on 2010/05/27 16:21 UTC
Read the original article Hit count: 163

Filed under:
|
|
|

Hi there

I want to convert a string to a generic type

I have this:

string inputValue = myTxtBox.Text;    

PropertyInfo propInfo = typeof(MyClass).GetProperty(myPropertyName);
Type propType = propInfo.PropertyType;

object propValue = ?????

I want to convert 'inputString' to the type of that property, to check if it's compatible how can I do that?

tks

© Stack Overflow or respective owner

Related posts about c#

Related posts about generics