Reputation: 11
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.
Upvotes: 1
Views: 59
Reputation: 3713
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.
Upvotes: 1