I have 6 Ranges:
1000000-5000000
50000001-10000000
10000001-25000000
25000001-50000000
50000001-75000000
75000001-100000000
Now how do I say th
You can declare class about this:
public class Range
{
public int Min { get; set; }
public int Max { get; set; }
public int Limit { get; set; }
public int Result{get;set;}
public Range(int min, int max, int limit, int result)
{
this.Min = min;
this.Max = max;
this.Limit = limit;
this.Result = result;
}
public bool InRange(int value)
{
if (value >= this.Min && value <= this.Max && value <= limit)
return true;
return false;
}
}
and use this class like:
List rangeList = new List();
rangeList.Add(new Range(1000000, 5000000, 10000000, 10));
rangeList.Add(new Range(5000001, 10000000, 10000000, 20));
int? result = rangeList.Where(t => t.InRange(value)).Select(t => t.Result).FirstOrDefault();
if variable result is not null, it's your final result.