In my code I have a Dictionary, which at first was just <string, int>. However, I needed a way for two things with the same string to be separate elements in the Dictionary, so I made the Key int and the Value a KeyValuePair<string, int>.
Dictionary<int, KeyValuePair<string, int>>()
The problem is, I need to check if a specific string exists in the Dictionary, preferably without the use of a for/foreach loop. Using Dictionary.ContainsValue I could check for a KeyValuePair, but the int in the KeyValuePair isn’t specified and would need to be if I used ContainsValue.
Is there any way to check if the Dictionary contains a KeyValuePair with a specific Key in one line?
If anyone has any other fixes for the problem that’d be great too.
Thanks in advance!