Revision: 31155
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 31, 2010 06:09 by wallybh
Initial Code
public class GenericConverter
{
public static T Parse<T>(string sourceValue) where T : IConvertible
{
return (T)Convert.ChangeType(sourceValue, typeof(T));
}
public static T Parse<T>(string sourceValue, IFormatProvider provider) where T : IConvertible
{
return (T)Convert.ChangeType(sourceValue, typeof(T), provider);
}
}
Initial URL
Initial Description
Enables to convert types using generics. Simple and clean.
Initial Title
C# Generic Type Conversion
Initial Tags
c
Initial Language
C#