Console Application in .Net
In this post, we will learn about Console Application in .Net with an example.
Definition – What does Console Application in .Net mean?
A console application,is an application that takes input and displays output at a command line console.
I make use of three basic data streams:
(1)standard input
(2)standard output
(3)standard error.
You can also read about C#.Net and Visual Studio which I have discussed in my previous posts.
A console application enable the reading and writing of characters from a console – either individually or as a set of entire line.It is the simplest form of a C# program and is typically invoked from the Windows command prompt.
A console application usually exists in the form of a stand-alone executable file(.exe) with least or no graphical user interface (GUI).
The program or code structure of a console application facilitates a sequential execution flow between statements.
A console application is mainly designed for the following purpose:
(1)To provide a simple user interface for applications requiring little or no user interaction, such as samples for learning C# language features and command-line utility programs.
(2)For Automated testing purpose which can decrease automation implementation resources.
To read a line of text from the console, you can use the Console.ReadLine() method.
This will read an input stream from the console and return the input string when user presses the Enter Key.
There are also two methods for writing to the console, which are used widely.
Console.Write() — Writes the specified value to the console.
Console.WriteLine() — This does almost the same, but adds a newline character at the end of the output.
To make C#.Net console appplication,
Open Visual Studio ->File -> New Project ->Visual C#-> select Console Applications.
Note:
When running a console application, it may automatically close the console window when the application ends, preventing you from seeing the actual output. To make the console application to wait until you press a key ,you need to add Console.ReadKey() or Console.Read() or Console.ReadLine() method at the end of the main method.
I hope you get an idea about Console Application in .Net.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you liked this post, don’t forget to share this.