<.> In the .NET, press the rolling symbol to divide the string
In the .NET, the default Split method may not be enough. This is a more comprehensive solution:
For this reason, we use the Split heavy load of the accepting string array:
This method is performed by a punishment string at each time of the interchangeation sequence (Environment.newline) defined by the operating system.
<code>string[] lines = theText.Split( new string[] { Environment.NewLine }, StringSplitOptions.None );</code>
Treatment of different changes
In some cases, you may encounter different texts with different formats. To deal with this situation, you can use Split to reload the ability to match multiple string:
The code after this modified is correctly divided by various string at the changing lines, including the Enter ("R"), the changing the row ("n") and the car Enter Essence It also retains the empty lines and spaces in the text.
The above is the detailed content of How Can I Reliably Split a String by Newlines in .NET?. For more information, please follow other related articles on the PHP Chinese website!