Using below extension method you can convert one type to another type.
public static T To(this object input) where T : IConvertible { string type = typeof(T).Name; TypeCode typecode; if (!Enum.TryParse(type, out typecode)) throw new ArgumentException("Could not convert!"); return (T)Convert.ChangeType(input, typecode); }
9:19 AM
Rajesh Rolen
0 comments:
Post a Comment