Answers for "dictionary c# string list"

C#
0

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
Posted by: Guest on April-08-2021
0

list dictionary c#

ListDictionary list = new ListDictionary();
list.Add("Hello", "Test1");
list.Add("Hello", "Test2");
list.Add("Hello", "Test3");
Posted by: Guest on March-31-2022
0

list dictionary c#

List<Dictionary<string, string>> MyList = new List<Dictionary<string, string>>();
Posted by: Guest on December-17-2020

C# Answers by Framework

Browse Popular Code Answers by Language