Why casting to object when comparing to null?

后端 未结 5 1822
故里飘歌
故里飘歌 2021-01-07 21:04

While browsing the MSDN documentations on Equals overrides, one point grabbed my attention.

On the examples of this specific page, some null checks are made, and the

5条回答
  •  失恋的感觉
    2021-01-07 21:46

    It is possible for a type to overload the == operator. The cast to object ensures that the original definition is used.

提交回复
热议问题