ReadLine Method in C sharp

The ReadLine method of the Console Class waits for the user input at Command prompt and once it reads the value entered by the user it brings the value into the program and return back as a String because the return type of this method is String.

Example



Output


In the above example we are using Parse Method. Parse is a method using which we can convert into a type on which the method is called.


Example
Note :-  Using Parse method for invalid type conversion will rise an error.
                             String s = "1105969";
                                   int j = int.Parse (s) //This code will rise an error.

No comments:

Post a Comment