I'd like to initialize a Dictionary with arrays of keys and values, as follows:
int[] keys = {1, 2, 3};
string[] values = {"a", "b", "c"};
Dictionary<int, string> dict = new Dictionary<int, string>(keys, values);
Is there a fast way to do it without iterating the arrays, as in:
for (int i = 0; i < keys.Length; ++i)
{
dict.Add(keys[i], values[i]);
}
EDIT: someone marked this question as a duplicate of this one, but they are unrelated, as that question doesn't ask about turning keys-values collections to a dictionary, but a list of objects, each object holding a key and a list of values, to a dictionary.