Read Console input

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
C# Code Snippets

C# Source Code Bank

See also …
edit

This C# code snippet reads either a character or a string from System.Console.

char character = (char) Console.Read();  // returns an int
 
string stringInput = Console.ReadLine();

In a Visual Studio console application, you can prevent the application from exiting and making your output window disappear by reading a single character from the Console. Then, just hit any key to exit.



Personal tools