System.Environment.NewLine

C# offers the System.Environment.NewLine which acts as "\r\n". The advantage of using the NewLine property is that it is platform sensitive.

In Windows, the carriage is represented as "\r\n" where as in Linux, it is "\n". Use System.Environment.NewLine property so that it works correctly on any platform.

Example:

string str= "Hello" + System.Environment.NewLine + "Sree";

Comments

Popular posts from this blog

Knowing too much is bad(in the world of OOP)

Reverse a LinkedList Algorithm

DateTime.Now in C#