[英]How to append double quote character to a string?
我正在嘗試將C#屬性創建為字符串,作為實驗的一部分,但出現錯誤“輸入字符串的格式不正確”。
這是因為quote
嗎?
如何正確在字符串后附加雙引號字符?
這是代碼:
string quote = "\"";
string propName = "MyPropName";
string propVal = "MyPropVal";
string csProperty = string.Format("public string {0} { get { return {1}; } }", propName, quote + propVal + quote);
轉義格式掩碼中不包含的大括號(通過加倍):
string csProperty = string.Format("public string {0} {{ get {{ return {1}; }} }}", propName, quote + propVal + quote);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.