What should a C# object initializer for a Dictionary<string, string[]> look like? -


i trying declare dictionary values string arrays. how can this?

i tried following code (which not work):

dictionary<string, string[]> newdic = new dictionary<string,string[]> {     {"key_0", {"value_0.0", "value_0.1"}},     {"key_1", {"value_1.0", "value_1.1", "value_1.2"}}, } 

you need specify values arrays like:

using implicitly typed array

 {"key_0", new[] {"value_0.0", "value_0.1"}}, 

or explicitly specifying type

 {"key_0", new string[] {"value_0.0", "value_0.1"}}, 

so class like:

public static class newclass {     private static dictionary<string, string[]> newdic = new dictionary<string, string[]>     {         {"key_0", new[] {"value_0.0", "value_0.1"}},         {"key_1", new string[] {"value_1.0", "value_1.1", "value_1.2"}},     }; } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -