本文介绍了哪个更高效," data.Length == 0"或QUOT;数据==&的String.Empty;?QUOT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查是否不变量字符串数据包含空字符串。

I want to check whether or not a variable string data contain empty string.

这是更有效, data.Length == 0 数据==的String.Empty

我忘了说了,数据已被检查,并保证是不是

I forgot to say, the data has been checked and it is guaranteed to be not null.

推荐答案

1亿次迭代测试结果:

Test results for 100 million iterations:

Equality operator ==:   796 ms
string.Equals:          811 ms
string.IsNullOrEmpty:   312 ms
Length:                 140 ms  [fastest]
Instance Equals:       1077 ms

这篇关于哪个更高效," data.Length == 0"或QUOT;数据==&的String.Empty;?QUOT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:31
查看更多