I have a list of ranges. Each range has a value from and to a value, that is, the value can be between this range. For example, if the range is (1,4)., Values ββcan be 1,2,3 and 4. Now I need to find different values ββin this range list. The following is sample code.
class Program
{
static void Main(string[] args)
{
List<Range> values = new List<Range>();
values.Add(new Range(1, 2));
values.Add(new Range(1, 3));
values.Add(new Range(1, 4));
values.Add(new Range(3, 5));
values.Add(new Range(7, 10));
values.Add(new Range(7, 8));
}
}
class Range
{
public Range(int _form, int _to)
{
from = _from;
to = _to;
}
private int from;
public int From
{
get { return from; }
set { from = value; }
}
private int to;
public int To
{
get { return to; }
set { to = value; }
}
}
I can go through each range and find different values. but if someone can give an effective approach, it would be helpful.
source
share