|
|
вернуться в форумHow to read data correctly, using C#??? This is my solution: ------------------------------------------------------- .....int a, b; .....string s; .....s = Console.ReadLine(); .....a = Int32.Parse(s.Substring(0, s.IndexOf(" "))); .....b = Int32.Parse(s.Substring(s.IndexOf(" "))); .....Console.WriteLine("{0}", a + b); ------------------------------------------------------- Are there some easier way to read two integers without Console.ReadLine(); or somthing else, if they are stored in the same line with space: 100 200 I think that a = Int32.Parse(s.Substring(0, s.IndexOf(" "))); is not good solution in this case. Re: How to read data correctly, using C#??? Послано Sal 25 фев 2007 17:28 String[] numbers = Console.ReadLine().Split(' '); try { Console.WriteLine(Int32.Parse(numbers[0]) + Int32.Parse(numbers[1])); } catch {} Re: How to read data correctly, using C#??? Послано Levdan 27 фев 2007 23:38 politeh rulit |
|
|