One of my friend asked me this question today morning and I was bit surprised. I mixed up things saying it must be something like scanf statements. Then I searched it and figured out the steps to do so.
In this code, Console.ReadLine() will accept an input from the keyboard and it will store it in specified variable. Here I wanted to read an integer value from keyboard, so I used Console.Read() first. Console.Read() accepts one character at a time. So it is of new use for accepting integer value. Int32.TryParse() function accepts the value and tries to convert it to integer. This function returns boolean value as success or failure.
In this code, Console.ReadLine() will accept an input from the keyboard and it will store it in specified variable. Here I wanted to read an integer value from keyboard, so I used Console.Read() first. Console.Read() accepts one character at a time. So it is of new use for accepting integer value. Int32.TryParse() function accepts the value and tries to convert it to integer. This function returns boolean value as success or failure.
No comments:
Post a Comment