Console.Read() Method in C#



The Console.Read() method in C# is used to read the next character from the standard input stream.

Syntax

The syntax is as follows −

public static int Read ();

Example

Let us now see an example to implement the Console.Read() method in C# −

using System;
public class Demo{
   public static void Main(){
      int val;
      Console.WriteLine("Enter a value");
      val = Console.Read();
      Console.WriteLine("Entered value: "+val);
   }
}

Output

This will produce the following output. Let’s say

Enter a value
Entered value: 53
Updated on: 2019-11-14T05:53:00+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements