C# variable or array with number range (example. 1 - 100)

arrays, c#, variables, visual-studio-2010

Solution

You can use `Enumerable.Range` to create a range of numbers:

int[] arr = Enumerable.Range(1, 100).ToArray();

Problem

I'm fairly new to C# and I'm doing a school project, i need to figure out how to get a variable or an array with numbers from 1 to 100 without entering every single number in an array for example `int[] numbersArray {1,2,3,4,5,6,7,8,9,10...};` because that takes a long time and doesn't look very efficient. I'm using C# Visual Studio Express 2010. It would mean alot to me if you could answer this for me. I'm gonna be using it in an if statement like so: ``` if(numbersArray.Contains(numbersInput)) { Console.WriteLine("numbersInput was a number from 1 to 100") } ```

Original source