You are correct, ReturnedType
should return the type that NullSafeGet will return. The example code you linked to is incorrect, ReturnedType
should return typeof(bool)
.
Also, getting the Equals method right is very important and I recommend a small change to your code:
public new bool Equals(object x, object y)
{
if (ReferenceEquals(x, y)) return true;
var xString = x as string;
var yString = y as string;
if (xString == null || yString == null) return false;
return xString.Equals(yString);
}