2012-07-21 26 views
-6

我想將該字符串轉換爲String.Format但我無法正確格式化該字符串。請如果你能幫助我。String.Format問題

string s = "$(\"#container\").notify();$(\"#container\").notify(\"create\", \"basic-template\", { title: '{0}', text: '{1}'},{ expires: false, speed: 1000 });"; 

我想這個到string.Format。我試圖轉換它,但它顯示我錯誤。輸入字符串格式不正確

+0

什麼樣的格式? – adatapost 2012-07-21 07:27:20

+0

嘗試:'「$(\」#container \「)。notify(); $(\」#container \「)。notify(\」create \「,\」basic-template \「,{{title:' {0}',text:'{1}'}},{{expires:false,speed:1000}});「' – 2012-07-21 08:10:34

回答

0

這工作?

string s = "$(\"#container\").notify();$(\"#container\").notify(\"create\", \"basic-template\", {{ title: '{0}', text: '{1}'}},{{ expires: false, speed: 1000 }});" 
+0

是的,這工作..非常感謝 – Moiz 2012-07-23 03:59:37

+0

我可以幫助的快樂 – 2012-07-23 06:20:59

1

您已得到{}字符串中的字符,這並不意味着string.Format替換。你需要將它們翻倍,{{}}

+0

我試過了,但在字符串中出現錯誤。 – Moiz 2012-07-21 07:30:39

+0

你得到了什麼錯誤?向我們顯示您的更新代碼。 – 2012-07-21 07:51:26