I have the following extension method
public static T Field<T>(this DataRow row, string columnName)
{
return (T)Convert.ChangeType(row[columnName], typeof(T));
}
It works, but I'm trying to speed it up. Is there a way to speed that up? With a case statement and then type specific conversions? I've tried a few things like using int.Parse, but even though I know I want an int returned, I have to use ChangeType to get it to compile.
return (T)Convert.ChangeType(intVal, typeof(T));