\n 相当于.NET 中的Environment.NewLine 吗?
大家好!
据我理解,当我们在双精度格式字符串中使用 .
符号时,它并不意味着“点”,它实际上意味着“当前环境中使用的小数分隔符”,所以如果我们正在工作对于非美国区域性设置,输出可以是 2,00
而不是 2.00
。这非常方便。
现在,对于 \n
(LF) 特殊符号来说也是如此吗?当格式字符串被解析时,它会变成 System.Environment.NewLine 符号,还是无论系统设置如何,它都始终是 0x0A 值? Environment.NewLine
有点啰嗦,我想知道我是否可以安全地使用 \n
来代替。
提前致谢。
Possible Duplicate:
Difference between “\n” and Environment.NewLine
Hello all!
The way I understand it, when we use .
symbol in format string for double, it doesn't mean "dot", it actually means "decimal separator used in current environment", so if we are working with non-US culture settings, the output can be 2,00
instead of 2.00
. That's quite handy.
Now, is it also true for \n
(LF) special symbol? Will it become System.Environment.NewLine
symbol when the format string gets parsed or will it always be 0x0A
value regardless of system settings? Environment.NewLine
is kinda wordy and I wonder if I can just use \n
safely instead.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这可能是您的答案“\n”和Environment.NewLine之间的差异
This is may be your answer Difference between "\n" and Environment.NewLine
使用它的目的是为了操作系统之间的可移植性
http://msdn .microsoft.com/en-us/library/system.environment.newline.aspx
The point of using it is for portability between OSs
http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx
如果您不喜欢输入 System.Environment.NewLine,请将本地变量设置为该值。
If you don't like typing out
System.Environment.NewLine
set a local var to that value.您可能应该意识到文本编写器也有一个 NewLine 属性
,即
我从头到尾都不太确定它是否总是与 System.Environment.NewLine 相同。比照。文档
You should probably aware that text writers have a
NewLine
property tooi.e.
I'm not too sure from the top of my head whether that would always by definition be the same as
System.Environment.NewLine
. Cf. the docs参考 Environment.NewLine 属性:
还:
Refering to Environment.NewLine Property:
Also: