gpt4 book ai didi

c# - 假设 this != null 在实现 IComparable

转载 作者:太空狗 更新时间:2023-10-29 23:10:49 25 4
gpt4 key购买 nike

我有一个 T 类型的对象实现IComparable<T> .执行的时候可以吗bool Equals (T obj)省略检查 if (ReferenceEquals(this, null)) { DoSomething() } ?我可以假设因为可以调用该函数 this已经不为空?

非常感谢。

最佳答案

是的,您可以假设如果函数已在对象上调用,则该对象不是null

关于c# - 假设 this != null 在实现 IComparable<T> 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5244747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com