Result of calling IEquatable.Equals(T obj) when this == null and obj == null?

前端 未结 7 525
鱼传尺愫
鱼传尺愫 2021-01-12 07:05

What should IEquatable.Equals(T obj) do when this == null and obj == null?

1) This code is generated

7条回答
  •  伪装坚强ぢ
    2021-01-12 07:50

    The reason F# does this (I suspect) to optimize empty lists as null.

    By adding this check, it allows one to call an instance method on a null instance without any problems.

    See my blog post from a while back.

    In C#, this is irrelevant.

    To answer the question:

    It should return true as both instances are null and deemed equal.

提交回复
热议问题