My question is not duplicate as the one that you have marked is searching List and I am trying to search Dictionary.
I have a Dictionary<string, Player>.
Player is an object with the properties GameID, Index and more. My dictionary key is player's index. I want to check if dictionary contains two Players with same GameID (the index will be different for those). One way of doing this is iterating with foreach over dictionary values and use an variable which would be incremented every time it encounters certain GameID. But I was wondering if there is a way to do this by using linq? If there is, that solution would probably be better.
.Values. But I got used to people who are prone to hating and giving minuses here on stackoverflow just because they understand something better then the othersValuesproperty,Dictionary<string, Player>isIEnumerable<KeyValuePair<string, Player>>. And LINQ to Objects operate onIEnumerable<T>regardless of what class is implementing it (array, list, dictionary, whatever). So it really doesn't matter what is the actual collection type. The only important is the element type. Take the accepted answer from the duplicate question, replacelstNames.GroupBy(n => n)withdict.GroupBy(x => x.Value.GameID)and there you go.