要去掉 C# 字符串中的回车符,可以使用 'Replace' 方法将回车符替换为空字符串。示例如下:

string input = 'Hello\r\nWorld!';
string output = input.Replace('\r\n', '');

Console.WriteLine(output); // 输出:HelloWorld!

在上述示例中,我们使用 '\r\n' 作为回车符的表示,然后使用 'Replace' 方法将其替换为空字符串。

C# 去掉字符串中的回车符

原文地址: http://www.cveoy.top/t/topic/ftlj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录