C# Newline Character Explained
In C#, the newline character can be represented using the special character “\n”. When \n is used in a string, it is interpreted as a newline character, causing the text to be displayed on a new line at that position. This is very useful when outputting data to the console or other text files, as it makes the text easier to read and understand. For example:
string text = "第一行\n第二行\n第三行";
Console.WriteLine(text);
The output will be:
第一行
第二行
第三行
The newline character \n can also be used in combination with other special characters, such as \t for tab, \r for carriage return, etc., allowing for more complex text formatting through various combinations.