Assuming this! = Null when implementing IComparable <T>

I have an object of type Tthat implements IComparable<T>. Is it possible to bool Equals (T obj)omit a check during implementation if (ReferenceEquals(this, null)) { DoSomething() }? Can I assume that since the function can be called thisno longer null?

Many thanks.

+5
source share
2 answers

Yes, you can assume that if a function was called on an object, then this object is not null.

+3
source

You should always accept this != null, because C # guarantees it.

+3
source

All Articles