How to replace space as a newline in a textBox with Multiline property set to true?

后端 未结 5 922
闹比i
闹比i 2021-01-28 23:14

Suppose I have this string:

string str = \"The quick brown fox     jumps over the lazy dog\";

How can I replace or ignore the spaces in the str

5条回答
  •  再見小時候
    2021-01-29 00:15

    string str = "The quick brown fox     jumps over the lazy dog";
    string[] ab = str.Split(' ');
    if (ab != null && ab.Length > 0)
    {
        string de = ab[0].Trim();
        for (int i = 1; i < ab.Length; i++)
        {
            de += "\n" + ab[i];
        }
    }
    

提交回复
热议问题