What’s the best way to handle this situation:
I have this generic function
Function FieldValue(Of T)(row As DataRow,fieldName As String) As T
Return If(row.IsNull(fieldName),Nothing,CType(row(fieldName),T))
End Function
in the special case where the field value is null and T is String, I want to return String.Empty instead of Nothing.
I think the easiest way is to provide a specific function for T = string:
(on top of your existing generic function)
Here’s another option: