- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use ReadKey() method of Console class in C#?
Console.ReadKey(); is for the VS.NET Users. This makes the program wait for a key press and it prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET.
A common use of the ReadKey() method is that you can halt the program execution. This could be done until a key is pressed by the user.
Let us see an example −
Example
using System; public class Demo { public static void Main() { DateTime date = DateTime.Now; TimeZoneInfo timeZone = TimeZoneInfo.Local; Console.WriteLine("Time Zone = {0}
", timeZone.IsDaylightSavingTime(date) ? timeZone.DaylightName : timeZone.StandardName); Console.Write(" to exit... "); while (Console.ReadKey().Key != ConsoleKey.Enter) {} } }
Output
Time Zone = UTC <Enter> to exit...
- Related Articles
- How to use WriteLine() method of Console class in C#?
- Console Class in C#
- How to use the Clear method of array class in C#?
- How to use the Clone() method of array class in C#?
- How to use the Copy(, ,) method of array class in C#
- How to use the CopyTo(,) method of array class in C#
- How to use the GetLength method of array class in C#?
- How to use the GetLongLength method of array class in C#?
- How to use the GetLowerBound method of array class in C#
- How to use the GetType method of array class in C#?
- How to use the GetUpperBound method of array class in C#?
- How to use the GetValue() method of array class in C#?
- How to use the IndexOf(,) method of array class in C#?
- How to use the Reverse() method of array class in C#
- How to use the SetValue(,) method of array class in C#?

Advertisements