How to read two integers in the same line in c#
Answers
Answered by
1
Explanation:
✍✍✍Python reads a line only in string format
To take multiple inputs from single line we just need to split the string.
So, it depends how your input string looks like. It needs a delimiter character like comma(“,”), or blank space(“ “) between your inputs in single line and then we will split the input.
Answered by
6
Answer:
Explanation:
One option would be to accept a single line of input as a string and then process it. For example:
//Read line, and split it by whitespace into an array of strings
string[] tokens = Console.ReadLine().Split();
//Parse element 0
int a = int.Parse(tokens[0]);
//Parse element 1
int b = int.Parse(tokens[1]);
Similar questions