字符串赋值 - 澄清 [英] String Assignment -Clarification
本文介绍了字符串赋值 - 澄清的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我声明时
string x = new string(new char[0]);
它工作正常.我的问题是什么值将分配给 x ?
It works fine.My question is what value will be assigned to x ?
当我检查
Console.WriteLine(x.CompareTo(null)==0);,it returns false.
推荐答案
当您分配新的 char[0] 时,您的字符串不为空.它是空的.
when you assign new char[0], your string is not null. It is empty.
你可以这样做:
Console.WriteLine(string.IsNullOrEmpty(x));
这篇关于字符串赋值 - 澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文