简体   繁体   中英

How to have a verbatim string literal inside a verbatim string literal?

如何在C#中存储类似以下字符串的内容:

string mystring = @"CMD.AddParameters("@Pkey", SqlDbType.Int, Pkey.ToString());";
string mystring = "CMD.AddParameters(\"@Pkey\", SqlDbType.Int, Pkey.ToString());";

要么

string mystring = @"CMD.AddParameters(""@Pkey"", SqlDbType.Int, Pkey.ToString());";
  • escape using the backslash:
    "CMD.AddParameters(\\"@Pkey\\", SqlDbType.Int, Pkey.ToString());"
  • use unicode literals:
    "CMD.AddParameters("@Pkey", SqlDbType.Int, Pkey.ToString());"

fwiw, here is a link to msdn on C# verbatim strings .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM