1

I need to only get the first Numbers of an input line from the console. If the console gives input being:

20 //this is some input text

Then I need my array to be only filled with the number 20 while still using console.readline.

David Thomas
  • 249,100
  • 51
  • 377
  • 410

1 Answers1

1

I'm guessing maybe you're working in C#???

Try this:

var line = "20 //this is some input text";
var num = int.Parse(line.Substring(0, line.IndexOf(' ')));

Then use the variable num for whatever you want. You can put it in an array like you want.

Dan
  • 3,583
  • 1
  • 23
  • 18