Hi,
 
I have the following piece of code:
 
string key = part.Split('=')[0];
PropertyInfo property = result.GetType().GetProperty(key);
if (property.PropertyType == typeof(string))
     property.SetValue(result, value, null);
else if (property.PropertyType == typeof(Int32))
    property.SetValue(result, Int32.Parse(value), null);
else if (property.PropertyType == typeof(bool))
    property.SetValue(result, bool.Parse(value), null);
 
My question is this:
 
Is there a way of generically typecasting the property value and not having to 
add an extra else if for each different type that the value might be.
Thanks
Paul
[EMAIL PROTECTED]
_________________________________________________________________
Celeb spotting – Play CelebMashup and win cool prizes
https://www.celebmashup.com/index2.html
===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to