DataRowExtensions.Field<'T> Method (DataRow, DataColumn, DataRowVersion)
Provides strongly-typed access to each of the column values in the specified row. Themethod also supports nullable types.
Assembly: System.Data.DataSetExtensions (in System.Data.DataSetExtensions.dll)
static member Field<'T> : row:DataRow * column:DataColumn * version:DataRowVersion -> 'T
The input DataRow, which acts as the this instance for the extension method.
The input DataColumn object that specifies the column to return the value of.
The value, of type T, of the DataColumn specified by column and version.
A generic parameter that specifies the return type of the column.
The value type of the underlying column could not be cast to the type specified by the generic parameter, T.
A null value was assigned to a non-nullable type.
The DataSet class represents null values with the Value instance of the DBNull class. A Language-Integrated Query (LINQ) expression that accessed a column with a null value would generate a InvalidCastException at run time. Additionally, DataSet doesn’t support nullable types. The method provides support for accessing columns as nullable types. If the underlying value in the DataSet is Value, the returned nullable type will have a value of null.
Themethod does not perform type conversions. If type conversion is required, you should first obtain the column value by using the method. The column value should then be converted to another type.
Available since 3.5