What is the difference between two, if any (with respect to .Net)?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Depends on the platform. On Windows it is actually "\r\n".
From MSDN:
Environment.NewLine
will return the newline character for the corresponding platform in which your code is runningyou will find this very useful when you deploy your code in linux on the Mono framework
From the docs ...
Environment.NewLine will give "\r\n" when run on Windows. If you are generating strings for Unix based environments, you don't want the "\r".
Exact implementation of
Environment.NewLine
from the source code:The implementation in .NET 4.6.1:
source
The implementation in .NET Core:
source (in
System.Private.CoreLib
)source (in
System.Runtime.Extensions
)You might get into trouble when you try to display multi-line message separated with "\r\n".
It is always a good practice to do things in a standard way, and use Environment.NewLine