我想在我的字符串中插入9個字之後插入一個換行符(\ n),以便第9個字之後的字符串在下一行中。在特定字數之後插入換行符
字符串換行=「如何將字符串(在這裏)第九字後插入換行符這樣剩餘字符串是下一行」
Stucked這裏:
foreach (char x in newline)
{
if (space < 8)
{
if (x == ' ')
{
space++;
}
}
}
不知道爲什麼我被困住了。我知道它很簡單。
如果可能,請顯示任何其他簡單的方法。
謝謝!
注意:爲自己找到了答案。由下面給出。
你所包含的代碼並沒有做你說你想要完成的事情,它只會計數空間。請包括您嘗試的完整代碼。另外,請詳細說明您遇到的錯誤/問題,以便我們可以更好地爲您提供幫助。通常這樣的問題要求我們「請給我一個codez!」將關閉。 –