I do not know what Location2D is, but you can use the following example to do what you want. Just sub in your class instead of string. In addition, since the values ββare not guaranteed to be unique in the dictionary (but may be in your case), you most likely want to do .Single () in the key enumeration.
[Test] public void Test() { var dictionary = new Dictionary<string, int> { { "first", 2 }, { "second", 1 }, { "third", 3 }, { "fourth", 1 } }; int min = dictionary.Values.Min(); IEnumerable<string> keys = dictionary.Keys.Where(key => dictionary[key] == min); Assert.That(keys.Count(), Is.EqualTo(2)); Assert.That(keys.Contains("second"), Is.True); Assert.That(keys.Contains("fourth"), Is.True); }
source share