public class DataServices
{
public static T? Coalesce<T>(T Obj, params T[] Args)
{
if (Obj != null && IsDBNull(Obj))
{
return Obj;
}
else
{
foreach (T arg in Args )
{
if (arg != null && IsDBNull(arg)) return arg;
}
}
return null;
}
public static Boolean IsDBNull(Object Value)
{
return DBNull.Value.Equals(Value);
}
}
Public Shared Function Coalesce(Of T)(ByVal obj As T, ByVal ParamArray Args() As T) As T
If obj IsNot Nothing AndAlso Not IsDBNull(obj) Then
Return obj
End If
For Each arg As T In Args
If arg IsNot Nothing AndAlso Not IsDBNull(obj) Then
Return arg
End If
Next
Return Nothing
End Function
Error 1 The type 'T' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable<T>' C:\Users\carl.symington\Documents\Vi sual Studio 2012\Projects\DataServices \DataServi ces\DataSe rvices.cs 11 26 DataServices
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE