ENVIRONMENT.NEWLINE IN.NET

It is ordinary to desire to add distinction breaks to book held in a progress or utilised for production purposes. In a Microsoft Windows surround a accepted distinction fortuity consists of digit carelessness characters. The prototypal is a posture convey and the ordinal a distinction feed. In a C# string, these crapper be represented as “\r\n”.

When you add a distinction fortuity to a string, it is not wise that you attach the digit carelessness characters manually. This is because code targeting the .NET support crapper be executed on non-Windows systems, which haw not ingest the aforementioned carelessness ordering for a distinction break. For example, Unix systems mostly ingest exclusive a distinction take carelessness case for a distinction fortuity and do not allow the posture return. Using both characters could thence drive cross-platform sympathy issues.

To hold this problem, the .NET support includes a concept that contains the precise carelessness ordering for a distinction break. This noise concept is institute in the Environment collection in the System namespace. The concept returns a distinction take progress that is pertinent to the underway operative system.

string newLine = Environment.NewLine;

Comments are closed.