-1

For example:

{1: 21, 2: 17, 3: 21}

the code would return 17

also it would have to work if theres only 1 item in the dictionary.

{1:5}

would return 5

Thanks!

1 Answers1

0

Do you want to get the key corresponding to the minimum value? If so, this should work:

Dictionary<int, int> d = new Dictionary<int,int>();
int key = d.First(t => t.Value == d.Values.Min()).Value;

If you just want the value, the following is enough:

Dictionary<int, int> d = new Dictionary<int,int>();
int minValue = d.Values.Min();
Michael
  • 1,557
  • 2
  • 18
  • 38