I am attempting to write this function in a generic manner so that it can handle float, double, decimal, or int.
It works except that the statement (increment * ti)
gives: "Operator * cannot be applied to operands of type T and int."
public static List<T> RangeIncrement<T>(T start, T end, T increment)
{
T range = (((dynamic)end - (dynamic)start) / increment) + 1;
if (TryCast(range, out int endRange))
{
return Enumerable
.Repeat(start, endRange)
.Select((tr, ti) => tr + (increment * ti))
.ToList();
}
return null;
}