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

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -