Having the following code is there a leaner way of initializing the array from 1 to the number especified by a variable?
int nums=5; int[] array= new int[num
Use Enumerable.Range() method instead of. Don't forget to add System.Linq namespace. But this could spend little bit high memory. You can use like;
int[] array = Enumerable.Range(0, nums).ToArray();
Generates a sequence of integral numbers within a specified range.