Programmatically using a tab character in .NET

前端 未结 4 1323
情歌与酒
情歌与酒 2020-12-18 18:31

Is there a way to use a tab character like a new line character inside the Environment class, instead of using \"\\t\"?

4条回答
  •  清歌不尽
    2020-12-18 19:09

    No.

    The only reason that Environment.NewLine exists at all is cross-platform issues, which the tab character doesn't have. The newline character is \r on (pre-OS X) Mac, \n on Unix, and \r\n on Windows.

    To allow .NET code to be portable across these platforms, the Environment.NewLine property was created, to return the newline character(s) used by the platform your code is running on.

    The tab character is standard across all platforms, so there's no point in making a property to return it.

提交回复
热议问题