C#
string returnValue = null; if (returnValue != null){
//
}--------------------------------------------------
string returnValue = null; if (returnValue == null){
//
}请问那个效率高了,谢谢雅
string returnValue = null; if (returnValue != null){
//
}--------------------------------------------------
string returnValue = null; if (returnValue == null){
//
}请问那个效率高了,谢谢雅
null的判断是查询指针指向。都是一次内存寻址。
ps:能不能不在这种无关大局的地方瞎折腾?研究回字有几种写法都比这有意义。
这个效率需要理解到汇编里面去了,
一般汇编里面会有一个 CMP 指令,对比两个数,
然后会把 对别结果设置对应的位,其中有 大于,等于,小于,不为零,的位数~!当然还要看看具体什么样的编译器,
编译器不一样,效率也有可能不一样~!