Can we enter 2 integer number (x and y) in one Console.Read () . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

31st Aug 2018, 6:43 AM
Nelly Gevorgyan
Nelly Gevorgyan - avatar
5 Answers
+ 4
Thanks a lot. I will try that way :)
31st Aug 2018, 7:03 AM
Nelly Gevorgyan
Nelly Gevorgyan - avatar
+ 2
Console.Write("Write x : " + x + "\nWrite y: " + y);
31st Aug 2018, 6:49 AM
Sam Pache
Sam Pache - avatar
+ 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]);
31st Aug 2018, 6:58 AM
Sam Pache
Sam Pache - avatar
+ 1
sorry I wrote rong not Condole.Write I need to know Console.Read can read 2 number in one Console?
31st Aug 2018, 6:54 AM
Nelly Gevorgyan
Nelly Gevorgyan - avatar
0
Try it and see
31st Aug 2018, 6:47 AM
Dan Walker
Dan Walker - avatar