I am trying to figure how to work with a list of KeyValuePairs in C#. I would use dictionaries but they do not allow for duplicate values.
Also the lookup which also i cannot figure out how to write the syntax.
I have seen other solutions but i am really confused on how to work with
Of course the only example i could find is with for loop, i would like to have it a little cleaner.
List<KeyValuePair<char, int>> data = new List<KeyValuePair<char, int>>();
I would like for example to do some checking before i add an element. For example: I have an array of characters, which i want to check before adding it to the my list. Can anyone tell me how to check.
char[] inputArray = input.ToCharArray();
for(int i = 0; i < inputArray.Length ; i++)
{
if(!data.Values.Contains(inputArray[i]))
{
data.Add(new KeyValuePair<char,int>(inputArray[i], 1));
}
}
The above code does not work. Could someone please help a bit with the syntax.
I did not found any concrete examples around the web. Any help is appreciated.