list dictionary c#
List<Dictionary<string, string>> MyList = new List<Dictionary<string, string>>();
list dictionary c#
List<Dictionary<string, string>> MyList = new List<Dictionary<string, string>>();
dictionary string list int c#
//init
Dictionary<string, List<int>> dictionaryStringListOfInt = new Dictionary<string, List<int>>(){
{ "The First", new List<int>(){ 1,2 } },
{ "The Second", new List<int>(){ 1,2 } }
};
//add a dictinary Key Value pair with a new empty list
//note you can add an existing list but be carful as it is a ref type and only pointing to ints (changes will be seen in original list ref)
dictionaryStringListOfInt.Add("The New", new List<int>());
//Add some values
dictionaryStringListOfInt["The New"].Add(1);
dictionaryStringListOfInt["The New"].Add(2);
//access some values via the Key and the values index
Console.WriteLine(dictionaryStringListOfInt["The New"][0]);//expected output 1
dictionaryStringListOfInt["The New"][0] = 3;
Console.WriteLine(dictionaryStringListOfInt["The New"][0]);//expected output 3
Console.WriteLine(dictionaryStringListOfInt["The New"][1]);//expected output 2
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us