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>>();
how to create dictionary of list in c#
public static void Main()
{
Dictionary<String, List<string>> dic = new Dictionary<string, List<string>>();
List<string> li1 = new List<string>();
li1.Add("text1"); li1.Add("text2"); li1.Add("text3"); li1.Add("text4");
List<string> li2 = new List<string>();
li2.Add("text1"); li2.Add("text2"); li2.Add("text3"); li2.Add("text4");
dic["1"] = li1;
dic["2"] = li2;
foreach (string key in dic.Keys)
{
foreach (string val in dic[key])
{
Console.WriteLine(val);
}
}
}
array list dictionary c#
int[] myIntArray = new int[10];
myIntArray[0] = 0;
myIntArray[1] = 10;
myIntArray[2] = 20;
myIntArray[3] = 30;
// Assignment via loop
for (int i=0; i<myIntArray.Length; i++)
{
myIntArray[i] = i * 10;
}
// Foreach loop over array
foreach (int element in myIntArray)
{
Console.WriteLine("${element}");
}
array list dictionary c#
using System.Collections.Generic;
List<string> myList = new List<string>();
myList.Add("Hello");
myList.Add("World");
myList.Add(10); // Compiler Error
array list dictionary c#
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
class Program
{
static void Main()
{
Dictionary<string, int> myDictionary = new Dictionary<string, int>();
myDictionary.Add("bob", 27);
myDictionary.Add("fred", 33);
int theAge = myDictionary["bob"];
}
}
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