【问题标题】:Verbatim string c# "'a\\\' b'" [duplicate]逐字字符串c#“'a\\\'b'” [重复]
【发布时间】:2021-07-13 19:21:53
【问题描述】:

我有字符串'a\\\' b',我需要制作算法来将此字符串转换为字符串'a' b'

  1. 'a\\\' b' = > 'a\\' b' => 'a\' b' = > 'a' b' 我怎么能做到?也许c#有一个方法可以检查char是否包含逐字符号?

【问题讨论】:

标签: c# verbatim-string


【解决方案1】:

您可以将反斜杠替换为空字符串。

string example = "'a\\\' b'";

Console.WriteLine(example.Replace("\\", string.Empty)); // Prints 'a' b'

【讨论】:

    猜你喜欢
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    • 2019-01-03
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    • 2012-03-30
    • 1970-01-01
    相关资源
    最近更新 更多