I had a string extension method to convert a Ranged String of numbers, such as "1-25,36,45,50-100", to an array of integers containing all number in the ranges. It has worked fine for years, however I now need it to work with uint numbers which can be much larger than a standard int. Which means this
public static uint[] RangedStringToArray(this string value)
{
var result = value.Split(',')
.Select(x => x.Split('-'))
.Select(p
=> new { First
= uint.Parse(p
.First()), Last
= uint.Parse(p
.Last()) }) .SelectMany(x => Enumerable.Range(x.First, x.Last - x.First + 1))
.OrderBy(z => z);
return result.ToArray<uint>();
}
now fails due to the Enumerable.Range only accepting integers. I know enough about Linq to fumble my way through getting things to work, most of the time. I did not write the above code (for integers) and I am having a difficult time trying to get this to work with uints. I could rewrite this to not use Linq, but I'd like to know if it is possible to keep it mostly as it is.