Methods of 'System.Nullable(Of T)' cannot be used as operands of the 'AddressOf' operator
A statement uses the AddressOf operator with an operand that represents a procedure of the Nullable structure.
Error ID: BC32126
To correct this error
Replace the procedure name in the AddressOf clause with an operand that is not a member of Nullable.
Write a class that wraps the method of Nullable that you want to use. In the following example, the NullableWrapper class defines a new method named GetValueOrDefault. Because this new method is not a member of Nullable, it can be applied to nullInstance, an instance of a nullable type, to form an argument for AddressOf.
Module Module1 Delegate Function Deleg() As Integer Sub Main() Dim nullInstance As New Nullable(Of Integer)(1) Dim del As Deleg ' GetValueOrDefault is a method of the Nullable generic ' type. It cannot be used as an operand of AddressOf. ' del = AddressOf nullInstance.GetValueOrDefault ' The following line uses the GetValueOrDefault method ' defined in the NullableWrapper class. del = AddressOf (New NullableWrapper( Of Integer)(nullInstance)).GetValueOrDefault Console.WriteLine(del.Invoke()) End Sub Class NullableWrapper(Of T As Structure) Private m_Value As Nullable(Of T) Sub New(ByVal Value As Nullable(Of T)) m_Value = Value End Sub Public Function GetValueOrDefault() As T Return m_Value.Value End Function End Class End Module