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的博文出现,我表示要作为一个吃瓜群众,静静的 ...
随机推荐
- 【BZOJ2554】Color 概率神题
[BZOJ2554]Color Description 有n个球排成一列,每个球都有一个颜色,用A-Z的大写字母来表示,我们每次随机选出两个球ball1,ball2,使得后者染上前者的颜色,求期望操作 ...
- [Bootstrap] install Bootstrap framework in window 7 by npm
Install with npm You can also install Bootstrap using npm: $ npm install bootstrap require('bootstra ...
- android通过数组,流播放声音的方法,音频实时传输
AudioRecord和AudioTrack类是Android获取和播放音频流的重要类,放置在android.media包中.与该包中 的MediaRecorder和MediaPlayer类不同,Au ...
- Linux系统下JDK安装配置(转载)
转载出处:http://www.cnblogs.com/xuliangxing/p/7066913.html 本文主要介绍的是如何是Linux环境下安装JDK的,因为Linux环境下,很多时候也离不开 ...
- nginx 下使用 bootstrap 字体的问题
使用boostrap时,出现 glyphicons-halflings-regular.ttf glyphicons-halflings-regular.woff glyphicons-halflin ...
- redis cluster 集群畅谈(二)
上一篇http://www.cnblogs.com/qinyujie/p/9029482.html, 主要讲解 redis cluster 集群 搭建,本篇主要讲解实验多master写入.读写分离.实 ...
- TA-Lib中文文档(二):talib安装
安装 使用pip安装 PyPI: $ pip install TA-Lib Or checkout the sources and run setup.py yourself: $ python se ...
- Python开发【整理笔记】
回顾笔记 学python半年,新知识不断填充,之前学的东西也忘的差不多,整理下笔记,把重点再加深下印象,算是读书拾遗吧.... 1.类继承.新式类.经典类 首先,新式类.经典类的概念只存在于Pytho ...
- Jquery EasyUI插件
属性 属性是定义在 jQuery.fn.{plugin}.defaults.比如,dialog 的属性是定义在 jQuery.fn.dialog.defaults. 事件 事件(回调函数)也是定义在 ...
- Struct2小结:
Action小结: 实现一个Action的最常用的方式:从ActionSupport继承: DMI动态方法调用,减少配置内容: 通配符 *_* ({1},{2})的使用更方便: 接收参数的方法(一般用 ...