I have two equally sized arrays, arrayKeys and arrayValues filled with data, respectively for Keys and Values, and an empty Dictionary<K, V>(myDictionary). I would like to assign as Keys and Values of the Dictionary the elements in each array. I know that this can be done by using the following code:
for(i=0:i<arrayKeys.Lenght;i++)
{
myDictionary.Add(arrayKeys[i], arrayValue[i]);
}
but I would like to know whether is there any way to perform the assignment as follows:
myDictionary.Keys = arrayKeys;
myDictionary.Values = arrayValues;
maybe by using lambdas with the ToDictionary method. Thanks in advance
Francesco
You can write