Nullable.Equals Method (Object)
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Overrides Function Equals ( _ other As Object _ ) As Boolean 'Usage Dim instance As Nullable(Of T) Dim other As Object Dim returnValue As Boolean returnValue = instance.Equals(other)
public boolean Equals ( Object other )
public override function Equals ( other : Object ) : boolean
Not applicable.
Parameters
- other
An object.
Return Value
true if the other parameter is equal to the current Nullable object; otherwise, false. This table describes how equality is defined for the compared values:| Return Value | Description |
|---|---|
| true | The HasValue property is false, and the other parameter is a null reference (Nothing in Visual Basic). That is, two null values are equal by definition. -or- The HasValue property is true, and the value returned by the Value property is equal to the other parameter. |
| false | The HasValue property for the current Nullable structure is true, and the other parameter is a null reference (Nothing in Visual Basic). -or- The HasValue property for the current Nullable structure is false, and the other parameter is not a null reference (Nothing in Visual Basic). -or- The HasValue property for the current Nullable structure is true, and the value returned by the Value property is not equal to the other parameter. |
The following code example determines whether an object and a Nullable object are equal to the current Nullable object.
' This code example demonstrates the Nullable(Of T).Equals ' methods. Imports System Class Sample Public Shared Sub Main() Dim nullInt1 As Nullable(Of Integer) = 100 Dim nullInt2 As Nullable(Of Integer) = 200 Dim myObj As Object ' Determine if two nullable of System.Int32 values are equal. ' The nullable objects have different values. Console.Write("1) nullInt1 and nullInt2 ") If nullInt1.Equals(nullInt2) Then Console.Write("are") Else Console.Write("are not") End If Console.WriteLine(" equal.") ' Determine if a nullable of System.Int32 and an object ' are equal. The object contains the boxed value of the ' nullable object. myObj = CType(nullInt1, Object) Console.Write("2) nullInt1 and myObj ") If nullInt1.Equals(myObj) Then Console.Write("are") Else Console.Write("are not") End If Console.WriteLine(" equal.") End Sub 'Main End Class 'Sample ' 'This code example produces the following results: ' '1) nullInt1 and nullInt2 are not equal. '2) nullInt1 and myObj are equal. '
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.