DataSetExtensionMethodsValueTValue Method |
Gets the value of the column with the column name specified from the DataRow in the type specified. If the value is DBNull.Value, null / Nothing
will be returned, if TValue is a nullable value type or a reference type, the default value for TValue will be returned otherwise.
Namespace:
SD.Tools.BCLExtensions.DataRelated
Assembly:
SD.Tools.BCLExtensions (in SD.Tools.BCLExtensions.dll) Version: 1.1.1
Syntax public static TValue Value<TValue>(
this DataRow row,
string columnName
)
<ExtensionAttribute>
Public Shared Function Value(Of TValue) (
row As DataRow,
columnName As String
) As TValue
Parameters
- row
- Type: System.DataDataRow
The row. - columnName
- Type: SystemString
Name of the column.
Type Parameters
- TValue
- The type of the value.
Return Value
Type:
TValuethe value of the column specified, or the default value for the type specified if not found.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
DataRow. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Remarks Use this method instead of Field(Of TValue) if you don't want to receive cast exceptions
See Also