【问题标题】:string s= @"somet"hing" what is wrong about this?string s= @"something" 这有什么问题?
【发布时间】:2010-06-21 11:08:13
【问题描述】:

我以为没有什么问题,但是 VS2010 报错了。

字符串 s= @"somet"hing";

【问题讨论】:

    标签: c# .net string escaping


    【解决方案1】:

    您需要在@ 字符串中使用双引号。

    string s = @"somet""hing";
    

    否则它怎么知道哪些引号是转义符,哪些是结束标记?

    请参阅the MSDN string page

    【讨论】:

    • w3.org/TR/html4" xmlns:f="w3schools.com/furniture">
      苹果 香蕉
      非洲咖啡桌80 120
      你能把所有这些都放到一个字符串中吗?引号已经加倍了。
    • 或给出如何将其轻松放入字符串的想法
    • @Freshblood:@"w3.org/TR/html4"" xmlns:f=""w3schools.com/furniture""> 苹果
      香蕉
      非洲咖啡桌:name> 80120
      "
    猜你喜欢
    • 2014-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    相关资源
    最近更新 更多