doramail05
asked on
Add key and value accordingly in Dictionary c#
try to make the dict collections output appear as
A 1
B 2
C 2
current display is :
A 1
B 1
C 1
A 1
B 2
C 2
current display is :
A 1
B 1
C 1
static void Main(string[] args)
{
string[] strArray = { "A", "B", "C" };
int[] intArray = { 1, 2, 3 };
Dictionary<string, int> dict = new Dictionary<string, int>();
foreach (string strArray01 in strArray)
{
foreach (int intArra01 in intArray)
{
dict.Add(strArray01, intArra01);
break;
}
}
foreach (KeyValuePair<string, int> kv in dict)
{
Console.WriteLine("Key : {0}, Value : {1}", kv.Key, kv.Value);
}
Console.ReadLine();
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
for (int i = 0; i <Â strArray.Length; i++)