Console.ReadLine() and Console.WriteLine()
Console.WriteLine():
We can store string values in string values in string objects and use these objects as parameters to the WriteLine() method. This method is used to convert the value of an object to its text representation and it represents in a string. The resulting string is written to the output stream.
Example:
using System; class Sample { public static void Main() { string subject="Hello C#"; // subject is assigned a string Console.WriteLine(subject); } }
Console.ReadLine():
Console.ReadLine() method is used to read the next line of characters from the standard input stream. If the standard input device is the keyboard, it blocks until the user presses the Enter key. If standard input is redirected to a file, it reads a line of text from a file.
Example:
using System; class Test { public static void Main() { Console.Write("Enter your name:"); string name= Console.ReadLine(); Console.WriteLine(+s,"007"); } }
Output:
Enter your name: James Bond
James Bond 007