为什么会出现类似的String.Empty没有Char.Empty? [英] Why is there no Char.Empty like String.Empty?

查看:191
本文介绍了为什么会出现类似的String.Empty没有Char.Empty?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有道理呢?我问这个,因为如果你需要使用大量的空字符,那么你进入相同的情况下,你会当你使用大量空字符串。

Is there a reason for this? I am asking this because if you needed to use lots of empty char, then you get into the same situation as you would when you use lots of empty strings.

编辑:这样做的原因用法是这样的:

The reason for this usage was this:

myString.Replace ('c', '')

因此​​,从myString中去掉'C的所有实例。

So remove all instances of 'c's from myString.

推荐答案

有没有这样的事,作为一个空字符。你可以得到的最接近的是'\ 0',单向code空字。既然你可以嵌入字符串或前preSS它自身很容易内,为什么你要为它单独的领域?同样,很容易混淆参数不办理'\ 0'

There's no such thing as an empty char. The closest you can get is '\0', the Unicode "null" character. Given that you can embed that within string literals or express it on its own very easily, why would you want a separate field for it? Equally, the "it's easy to confuse "" and " " arguments don't apply for '\0'.

如果你能给的,你会想使用它,为什么你认为这将是更好的例子,这可能有助于...

If you could give an example of where you'd want to use it and why you think it would be better, that might help...

这篇关于为什么会出现类似的String.Empty没有Char.Empty?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆