今天很簡單,我想。在C#中,它的:在聲明中添加鍵/值到詞典
Dictionary<String, String> dict = new Dictionary<string, string>() { { "", "" } };
但是在vb中,以下不起作用。
Public dict As Dictionary(Of String, String) = New Dictionary(Of String, String) (("",""))
我很確定有一種方法可以在聲明中添加它們,但我不知道如何。是的,我想在聲明中添加它們,而不是其他時間。 :)所以希望這是可能的。感謝大家。
我也試過:
Public dict As Dictionary(Of String, String) = New Dictionary(Of String, String) ({"",""})
而且......
Public dict As Dictionary(Of String, String) = New Dictionary(Of String, String) {("","")}
而且......
Public dict As Dictionary(Of String, String) = New Dictionary(Of String, String) {{"",""}}
罰款!我不知道這是如何表現的,它是否先構建二維數組,然後將其複製到字典中? – vulkanino 2010-09-22 17:34:11
Dern。所以你說,因爲我使用VS2008,我無法做到這一點?那臭味。 – XstreamINsanity 2010-09-22 17:43:10
Yeap,有點臭:-)升級的時間。 – 2010-09-22 17:44:45