I have dictionary containing key value pairs.
SortedDictionary dictionary=new SortedDictionary();
dictionary.Add(1,33);
diction
I would prefer to use linq if that's the case... try this it will surely work
SortedDictionary dictionary = new SortedDictionary();
dictionary.add(1, 33);
dictionary.add(2, 20);
dictionary.add(4, 35);
int SelectedKey = 4;
var ResutValue = ( from n in dictionary
where n.Key < TheSelectedKey
select n.Value).Last();
this.txtResult.Text = ResultValue.ToString();