I want to convert a string to a generic type
I have this:
string inputValue = myTxtBox.Text;
PropertyInfo propInfo = typeof(MyClass).GetProperty
using System.ComponentModel;
TypeConverter typeConverter = TypeDescriptor.GetConverter(propType);
object propValue = typeConverter.ConvertFromString(inputValue);
I don't really think I understand what your are trying to archieve, but.. you mean a dynamic casting? Something like this:
TypeDescriptor.GetConverter(typeof(String)).ConvertTo(myObject, typeof(Program));
Cheers.
Try Convert.ChangeType
object propvalue = Convert.ChangeType(inputValue, propType);