I have this dictionary:
Dictionary<char, ValuePair> dictionary = new Dictionary<char, ValuePair>();
With the following struct:
struct ValuePair
{
public double Value1;
public double Value2;
}
With the following values:
dictionary.Add('A', new ValuePair { Value1 = 0.0, Value2 = 1.0 });
dictionary.Add('B', new ValuePair { Value1 = 1.0, Value2 = 1.2 });
dictionary.Add('C', new ValuePair { Value1 = 1.2, Value2 = 1.4 });
dictionary.Add('D', new ValuePair { Value1 = 1.4, Value2 = 1.6 });
dictionary.Add('E', new ValuePair { Value1 = 1.6, Value2 = 1.8 });
dictionary.Add('F', new ValuePair { Value1 = 1.8, Value2 = 2.0 });
dictionary.Add('G', new ValuePair { Value1 = 2.0, Value2 = double.MaxValue });
With query syntax I'm checking if a value is between one of the values, or if the case is G it justneed to be greater than 2.0. I don't like the solution with double.MaxValue. Is there any other way?
var getValue = (from d in dictionary
where 2.1 >= d.Value.Value1 && 2.1 < d.Value.Value2
select d.Key).FirstOrDefault();
Console.WriteLine(getValue);
Thanks