How to use Field<T> with Type?
I have a method that determines the min and max of a column in a `DataTable`:


    public void GetMinMaxRange( DataTable data, string valueColumnName )
    {
       var min = data.AsEnumerable().Min(m => m.Field<double>(valueColumnName));
       var max = data.AsEnumerable().Max(m => m.Field<double>(valueColumnName));
    }

I want to refactor this to be:

    public void GetMinMaxRange( DataTable data, string valueColumnName )
    {
       DataColumn column = data.Columns[valueColumnName];
       var min = data.AsEnumerable().Min(m => m.Field<column.DataType>(valueColumnName));
       var max = data.AsEnumerable().Max(m => m.Field<column.DataType>(valueColumnName));
    }

I need to determine the datatype and use it instead of hard-coding `m.Field<double>`.  How to do this?


How to use Field<T> with Type?
===

I have a method that determines the min and max of a column in a `DataTable`:


    public void GetMinMaxRange( DataTable data, string valueColumnName )
    {
       var min = data.AsEnumerable().Min(m => m.Field<double>(valueColumnName));
       var max = data.AsEnumerable().Max(m => m.Field<double>(valueColumnName));
    }

I want to refactor this to be:

    public void GetMinMaxRange( DataTable data, string valueColumnName )
    {
       DataColumn column = data.Columns[valueColumnName];
       var min = data.AsEnumerable().Min(m => m.Field<column.DataType>(valueColumnName));
       var max = data.AsEnumerable().Max(m => m.Field<column.DataType>(valueColumnName));
    }

I need to determine the datatype and use it instead of hard-coding `m.Field<double>`.  How to do this?

