How can I convert a string with newlines in it to separate lines?

前端 未结 5 508
感情败类
感情败类 2021-01-23 21:46

How to convert string that have \\r\\n to lines?

For example, take this string:

string source = \"hello \\r\\n this is a test \\r\\n tested\         


        
5条回答
  •  情书的邮戳
    2021-01-23 22:40

    In addition to string.Split which is mentioned, you can also use Regex.Split, but it's often more useful for more complicated split patterns.

    var lines = Regex.Split( source, @"\r\n" );
    

提交回复
热议问题