Using KeyValuePair as the key for your dictionary:
It will functionally work to use a KeyValuePair as the key in a dictionary; however, conceptually probably not the best choice for your application as it implies the Key-Value relationship between the two ints.
Instead as Mike suggests you should use Tuple for your key.
For the second question:
var myDictionary = new Dictionary<KeyValuePair<int,int>, string>();
myDictionary.Add(new KeyValuePair<int,int>(3, 3), "FirstItem");
myDictionary.Add(new KeyValuePair<int,int>(3, 3), "SecondItem");
// does the dictionary allow this?
The dictionary will not allow this, dictionaries themselves are sets of key-value pairs where the keys must be unique. If you want to be able to map mulitple values to the same key, one option would be to have the value be another collection:
var myDictionary = new Dictionary<KeyValuePair<int,int>, List<string>>();
but then you would still not be able to use myDictionary.Add as in your example.
instead you would have to provide additional functionality to determine if they key were part of the dictionary and act accordingly:
public static class DictionaryHelper
{
public static void Add(this Dictionary<Tuple<int,int>, List<string>> dict,Tuple<int,int> key, string value)
{
if(dict.ContainsKey(key))
{
dict[key].Add(value);
}
else
{
dict.Add(key, new List<string>{value});
}
}
}