0

System.Console.ReadLine() vs Console.ReadLine()

What is the difference between System.Console.ReadLine() and Console.ReadLine()??

9th Apr 2017, 6:15 AM
John Devaule
3 Answers
+ 8
There is generally no difference between the two. In the system namespace, console is a static class. Hence, if you did: using System; in your code, you don't have to specify the namespace again to call the console class. (But you can if you want to, honestly it wouldn't make any difference.) Sometimes if 2 class have the same name, you would have to specify which namespace you are using. and finally, ReadLine() is a method/function from the class Console of course!
9th Apr 2017, 6:21 AM
Wen Qin
Wen Qin - avatar
+ 11
There's no difference. You call ReadLine() from the Console class, which is in the System namespace. Writing "using System" allows you to skip typing out the namespace every time.
9th Apr 2017, 6:23 AM
Tamra
Tamra - avatar
+ 4
If u r "using System" namespace then no need to write System.Console.ReadLine. Hope u got it.
10th Apr 2017, 4:56 AM
Aditya Gupta
Aditya Gupta - avatar