+ 2
Can we enter 2 integer number (x and y) in one Console.Read () .
In my programm I need enter two integer number that depend on the choozed action must + , - , * , .... I what enter 2 integer number at the same time. Can I? Please give direction. Thank you in advance.
5 Answers
+ 4
Thanks a lot. I will try that way :)
+ 2
Console.Write("Write x : " + x + "\nWrite y: " + y);
+ 2
From StackOverflow : https://stackoverflow.com/questions/3881826/reading-two-integers-in-one-line-using-c-sharp
//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]);
+ 1
sorry I wrote rong not Condole.Write I need to know Console.Read can read 2 number in one Console?
0
Try it and see