In VB.Net you can write :
If Not IsDBNull(oCustomerNameDataRow(0)) Then
cbCustomerName.Items.Add(oCustomerNameDataRow(0).ToString
End If
What is the equivalent of method IsDBNull in C#?
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C.
C was originally developed for UNIX operating system to beat the issues of previous languages such as B, BCPL, etc. The UNIX operating system development started in the year 1969, and its code was rewritten in C in the year 1972.
if (!DBNull.Value.Equals(oCustomerNameDataRow[0]))
{
//something
}
MSDN (DBNull.Value)
I would say the the equivalent of the IsDBNull method (Microsoft.VisualBasic.Information) located in the Microsoft.VisualBasic assembley
Public Function IsDBNull(ByVal Expression As Object) As Boolean
If Expression Is Nothing Then
Return False
ElseIf TypeOf Expression Is System.DBNull Then
Return True
Else
Return False
End If
End Function
Dim result As Boolean = IsDBNull(Nothing)
is the IsDBNull method (System.Convert) located in the mscorlib assembley:
public static bool IsDBNull(object value) {
if (value == System.DBNull.Value) return true;
IConvertible convertible = value as IConvertible;
return convertible != null? convertible.GetTypeCode() == TypeCode.DBNull: false;
}
bool result = System.Convert.IsDBNull(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With