Environment.NewLine
https://docs.microsoft.com/en-us/dotnet/api/system.environment.newline?view=netframework-4.7.2
https://stackoverflow.com/questions/1015766/difference-between-n-and-environment-newline
Answer1
Exact implementation of Environment.NewLine from the source code:
The implementation in .NET 4.6.1:
/*===================================NewLine====================================
**Action: A property which returns the appropriate newline string for the given
** platform.
**Returns: \r\n on Win32.
**Arguments: None.
**Exceptions: None.
==============================================================================*/
public static String NewLine {
get {
Contract.Ensures(Contract.Result<String>() != null);
return "\r\n";
}
}
The implementation in .NET Core:
/*===================================NewLine====================================
**Action: A property which returns the appropriate newline string for the
** given platform.
**Returns: \r\n on Win32.
**Arguments: None.
**Exceptions: None.
==============================================================================*/
public static String NewLine {
get {
Contract.Ensures(Contract.Result() != null);
#if !PLATFORM_UNIX
return "\r\n";
#else
return "\n";
#endif // !PLATFORM_UNIX
}
}
source (in System.Private.CoreLib)
public static string NewLine => "\r\n";
source (in System.Runtime.Extensions)
Answer2
As others have mentioned, Environment.NewLine returns a platform-specific string for beginning a new line, which should be:
"\r\n"(\u000D\u000A) for Windows"\n"(\u000A) for Unix"\r"(\u000D) for Mac (if such implementation existed)
Note that when writing to the console, Environment.NewLine is not strictly necessary. The console stream will translate "\n" to the appropriate new-line sequence, if necessary.
Just a note, that would be old macs; new (OSX) macs use \n
Environment.NewLine的更多相关文章
- C#换行 System.Environment.NewLine。
为保持平台的通用性,可以用系统默认换行符 System.Environment.NewLine.
- C# 跨平台换行符 System.Environment.NewLine
C# 跨平台换行符 System.Environment.NewLine
- Environment类,获取程序所在机器信息
一.属性 CommandLine 获取该进程的命令行.CurrentDirectory 获取或设置当前工作目录的完全限定路径.ExitCode 获取或设置进程的退出代码.HasShutdownSta ...
- Environment 类
提供有关当前环境和平台的信息以及操作它们的方法. 此类不能被继承. using System; using System.Collections; using System.Collections.G ...
- C# Environment类_获取程序所在机器信息
一.属性 CommandLine 获取该进程的命令行.CurrentDirectory 获取或设置当前工作目录的完全限定路径.ExitCode 获取或设置进程的退出代码.HasShutdownSta ...
- C#核编之System.Environment类
在前面的例子中用来了Environment.GetCommandLineArgs()这个方法,这个方法就是获取用户的命令行输入,是Environment类的方法之一,该方法的返回值是string[] ...
- Environment类包含的几个有用的方法
1.获取操作系统版本(PC,PDA均支持) Environment.OSVersion 2.获取应用程序当前目录(PC支持) Environment.CurrentDirectory 3.列举本地硬盘 ...
- C# 使用Environment获取当前程序运行环境相关信息
Enviroment类和AppDomain类前者表示系统级的相关信息,后者表示应用程序级的相关信息. 我常用这两个类获取一些程序运行目录.操作系统位数等信息: string basedir = App ...
- 关于.NET异常处理的思考
年关将至,对于大部分程序员来说,马上就可以闲下来一段时间了,然而在这个闲暇的时间里,唯有争论哪门语言更好可以消磨时光,估计最近会有很多关于java与.net的博文出现,我表示要作为一个吃瓜群众,静静的 ...
随机推荐
- POJ2286 The Rotation Game[IDA*迭代加深搜索]
The Rotation Game Time Limit: 15000MS Memory Limit: 150000K Total Submissions: 6325 Accepted: 21 ...
- Python 导入与注册
背景 最近一直学习写一个POC扫描框架,但是不知道如何下手,正巧因为一些需要有朋友在研究POCSuite的实现原理,顺面蹭一些知识点,补一补Python基础的不足,为以后编写POC框架打地基. 导入 ...
- 【BZOJ5082】弗拉格 矩阵乘法
[BZOJ5082]弗拉格 Description “如果明天进了面试,我就去爆妹子的照”——有妹子的丁相允作为一个oier,自然不能立太多flag,让我们来看一道和flag有关的题目吧 给你n个fl ...
- Windows Phone 几种页面间传递数据的方式
首先,我们要引用:using Microsoft.Phone.Shell; 第一种: // 导航到新页面 NavigationService.Navigate(new Uri("/Detai ...
- Nexus介绍
转自:https://www.cnblogs.com/wincai/p/5599282.html 开始在使用Maven时,总是会听到nexus这个词,一会儿maven,一会儿nexus,当时很是困惑, ...
- jdbc将数据库连接信息放置配置文件中
目录如下: jdbcConnection.java: package jdbc01; import java.io.InputStream; import java.sql.Connection; i ...
- Css-常用css
/*怪异盒子模型*/ .box { box-sizing: border-box; } /*水平居中的内联块级*/ .inBlock { display: inline-block; vertical ...
- 持续集成之jenkins2
ip 什么是持续集成 没有持续集成 持续集成最佳实践 持续集成概览 什么是Jenkins Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开 ...
- poj3171 Cleaning Shifts【线段树(单点修改区间查询)】【DP】
Cleaning Shifts Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4422 Accepted: 1482 D ...
- LightGBM值参数配置
LightGBM 可以使用一个 pairs 的 list 或一个字典来设置参数: 1.Booster提升器的参数: param={'num_class':33, 'boosting_type':'gb ...