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 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

Recommended Posts:

C#
    1. C# Features
    2. Difference Between C++ and C#
    3. Difference Between C# and Java
    4. .NET Framework
    5. Benefits of .NET
    6. C# Program Structure
    7. C# Command Line Arguments
    8. Console.ReadLine() and Console.WriteLine()
    9. C# Literals
    10. C# Data Types
    11. Scope of Variables in C#
    12. Boxing and Unboxing in C#
    13. C# Operators
    14. C# Type Casting