2009-10-16 36 views
1

我想將這些字符串放在列表中,我該怎麼做?舉行是在前兩行發現的雙重""。我該如何解決這個問題?從列表中解析出文本中的引用

scriptTxt = new string[] 
{ 
    "#$language = "VBScript"", 
    "#$interface = "1.0"", 
    "crt.Screen.Synchronous = True", 
    "Sub Main" 
}; 

回答

5
scriptTxt = new string[] 
{ 
    "#$language = \"VBScript\"", 
    "#$interface = \"1.0\"", 
    "crt.Screen.Synchronous = True", 
    "Sub Main" 
}; 

或者

scriptTxt = new string[] 
{ 
    @"#$language = ""VBScript""", 
    @"#$interface = ""1.0""", 
    "crt.Screen.Synchronous = True", 
    "Sub Main" 
}; 
+0

您需要第二個字符串的另一個@符號,因爲1.0也有引號。 – Brandon 2009-10-16 14:47:02

1

使用反斜線引號。 (撇號是')

scriptTxt = new string[] 
{ 
    "#$language = \"VBScript\"", 
    "#$interface = \"1.0\"", 
    "crt.Screen.Synchronous = True", 
    "Sub Main" 
};