I want to enter in a bunch of integers like so:
1 11 2 12 3 13 4 14 5 56 6 80...

How would I get them into an array of int?

Console.WriteLine("Enter in numbers");

 string answer = Console.ReadLine();

  int[] myArray = new int[answer.Length]; 
 for (int i = 0; i < answer.Length; i++)
        {
            myArray[i] = answer[i].ToString();
        }

The problem with that code is that it doesnt see the space inbetween numbers. Any ideas?

char[] space = new char[1] { ' ' };
Console.WriteLine("Enter in numbers");
int nAnswer;
string[] answer = Console.ReadLine().Split(space
           ,StringSplitOptions.RemoveEmptyEntries);
                
List<int> myArray = new List<int>();
foreach(string str in answer)
     if( Int32.TryParse(str,out nAnswer) )
                    myArray.Add(nAnswer);

// Your answer can be pulled from the list using:
int[] result = myArray.ToArray();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.