I have an object of type T
which implements IComparable<T>
. Is it okay when implementing bool Equals (T obj)
to ommit the check if (ReferenceEquals(this, null)) { DoSomething() }
? Can I assume that since the function could be called this
is already not null?
Thank you very much.
Yes you can assume that if the function has been called on an object, then that object is not null
.
You should always assume this != null
, because C# guarantees it.
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