I am porting a C# struct over to VB.NET and am facing the following problem:
The struct is used to safely invoke methods on objects without the need to check for null all the time. It has exactly one generic member, which can be null:
mValue As T
The GetHashCode method is implemented like that:
public override int GetHashCode()
{
if (this.mValue != null)
{
this.mValue.GetHashCode();
}
return base.GetHashCode();
}
In the VB.NET implementation I cannot do
Return MyBase.GetHashCode()
because MyBase is not valid within a structure.
I have read this comment on how ValueType.GetHashCode is implemented.
According to this, in my example, I could probably just use
Return Me.GetType().GetHashCode()
for the case where mValue is null.
But this does not seem like a very solid implementation to me. Is there some simple way to call base.GetHashCode() for a structure in VB.NET?