相关疑难解决方法(0)

从字符串c#中删除'\'字符

我有以下代码

string line = ""; 

while ((line = stringReader.ReadLine()) != null)
{
    // split the lines
    for (int c = 0; c < line.Length; c++)
    {
        if ( line[c] == ',' && line[c - 1] == '"' && line[c + 1] == '"')
        {
            line.Trim(new char[] {'\\'}); // <------
            lineBreakOne = line.Substring(1, c  - 2);
            lineBreakTwo = line.Substring(c + 2, line.Length - 2);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经在我想知道的行中添加了评论网.我想从字符串中删除所有'\'字符.这是正确的方法吗?我不工作.所有\仍然在字符串中.

c# trim

36
推荐指数
7
解决办法
19万
查看次数

标签 统计

c# ×1

trim ×1