0
我想處理一個字符串,以便它不包含回車符,但是我遇到了一些麻煩。我目前正在使用:如何從字符串中刪除回車返回
Visual Studio 2010中:
strText = strText.Replace(vbCr, "")
回車沒有被刪除,謝謝。
我想處理一個字符串,以便它不包含回車符,但是我遇到了一些麻煩。我目前正在使用:如何從字符串中刪除回車返回
Visual Studio 2010中:
strText = strText.Replace(vbCr, "")
回車沒有被刪除,謝謝。
你試過
strText = strText.Replace("\n\r", "");
或
strText = strText.Replace("\n", "");
或
strText = strText.Replace("\r", "");
或
strText = strText.TrimEnd('\r', '\n');
的另一個選項使用'Environment.NewLine'而不是硬編碼的字符串。 – 2013-04-26 15:41:51
的確如此,那會更好。 – 2013-04-26 15:42:28
雖然在Visual Basic中'vbCrLf'可能是正確的常量。從而提示這個問題。 – 2013-04-26 15:45:44