I need help finding out how i can merge 2 dictionaries together, creating one.
i have this code so far:
using System;
using System.Collections.Generic;
namespace merging_dictionaries
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, string> dict = new Dictionary<string, string>
{
{ "WA", "Western Autralia" },
{ "NSW", "New South Wales" },
{ "SA", "South Australia" },
{ "Q", "Queensland" },
{ "V", "Victoria" },
{ "T", "Tasmania" }
};
Dictionary<string, string> otherdict = new Dictionary<string, string>
{
{ "1", "Adclarkia dawsonensis" },
{ "2", "Advena campbellii " },
{ "3", "Discocharopa vigens" },
{ "4", "Hyridella glenelgensis" },
{ "5", "Mathewsoconcha grayi ms" },
{ "6", "Mathewsoconcha phillipii" }
};
MergeDictionary(dict, otherdict);
}
public static Dictionary<string, string> MergeDictionary(Dictionary<string, string> dict1, Dictionary<string, string> dict2)
{
foreach (var thing in dict1)
{
dict2.Add(thing.Key);
dict2.Add(thing.Value);
}
}
}
}
I can't make this work as intended, if at all.
Please help me fix it.
Thank you.
What I have tried:
I ave tried different ways of putting the dictionaries together with no success.
I have tried different ways of adding the keys and values, one at a time or all together, to no avail.