have you any alternative to these code, i want a more generic code
I tried Convert class but with no success
public object convert(Type type, string value)
{
object r = null;
if (type == typeof(bool))
{
r = bool.Parse(value);
}
else if (type == typeof(int))
{
r = int.Parse(value);
}
else if (type == typeof(string))
{
r = value;
}
return r;
}
Other conversion operations exist if you don’t want “invariant”. It depends on your needs. See also
ConvertFromStringif you want locale settins to apply, etc.