三种常用的字符串判空串方法:
1: bool isEmpty = ( str.Length == 0 );
2: bool isEmpty = ( str == String.Empty );
3: bool isEmpty = ( str == "" );
哪种方法最快?
1: bool isEmpty = ( str.Length == 0 );
2: bool isEmpty = ( str == String.Empty );
3: bool isEmpty = ( str == "" );
哪种方法最快?
第一个str.Length要算一次再做一个==0的判断
第二个String.Empty也要先做一次空的操作再==判断
只有第三个只做一次==判断
str.empty其实就是“”,但没有直接=“”效率高
1项好像不对
这个 这里有人做的试验..你看一下,可能对你有帮助