本文介绍了我现在总是使用String.Empty而不是“&quot;”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 过去我总是使用"在我的代码中到处都是空字符串 没有问题。 现在,你认为我应该使用String.Empty而不是" (总共 次)? 让我知道你的想法。 解决方案 如果你要检查空字符串,最好使用: String.IsNullOrEmpty(strStringName) 从.NET 2.0开始 - 快乐编码! Morten Wennevik [C#MVP] 您觉得哪个更容易阅读?这是任何重要的唯一 差异,IMO。 - Jon Skeet - < sk***@pobox.com> http://www.pobox。 com / ~siget 博客: http://www.msmvps.com/ jon.skeet 如果回复小组,请不要给我发邮件 In the past I always used "" everywhere for empty string in my codewithout a problem.Now, do you think I should use String.Empty instead of "" (at alltimes) ?Let me know your thoughts. 解决方案If you''re checking for an empty string it''s better to use:String.IsNullOrEmpty(strStringName)As of .NET 2.0--Happy Coding!Morten Wennevik [C# MVP]Which do you find easier to read? That''s pretty much the onlydifference of any significance, IMO.--Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeetIf replying to the group, please do not mail me too 这篇关于我现在总是使用String.Empty而不是“&quot;”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 14:32
查看更多