tags:

views:

71

answers:

2

I have string value and Type of some variable (For example int and "32" or bool and true). My type is primitive type. Can I parse string to my type in one line?

+4  A: 

Yes.

Convert.ChangeType(value, type);
SLaks
A: 
object res = Convert.ChangeType("123", myType);
Darin Dimitrov