What is Console Application


        A console application is an application that runs in a console window same as a C and C++ program.

It doesn’t have any graphical user interface. Console Applications will have character based interface. 


what is console application

To work with console applications in .NET you have to use a class called Console that is available within the namespace System, which is the root namespace.


Console Application in C#

To read a line of text from the console window, you use the Console.ReadLine() method.
This will read an input stream  from the console window and return the input string when user presses the Enter Key.

There are also two methods for writing to the console, which are used extensively

  • Console.Write() — Writes the specified value to the console window.
  • Console.WriteLine() — This does the same, but adds a newline character at the end of the output.

Example:

The below C#.NET code lets the user input a line of text and displays that text

string s = Console.ReadLine();
Console.WriteLine(s);


To write C# console program , 
Open Visual Studio ->File -> New Project ->Visual C#-> select Console Applications 

Console Application C#


Example for Console Application in C#.NET to print sum of 2 numbers

C# program sample

using System;

namespace ProgramCall
{
    class Program
    {

        static void Main(string[] args)
        {

            int A, B, SUM;

            Console.WriteLine("Enter Two Integers"); 

            A = int.Parse(Console.ReadLine());

            B = int.Parse(Console.ReadLine());
            SUM = A + B;
            Console.WriteLine("Sum  Of  {0}  And  {1}  Is  {2}", A, B, SUM);
            Console.Read();// To prevent console from vanishing
        }
    }

}

OUTPUT
----------
Enter Two Integers
12
45
Sum  Of  12  And  45  Is  57


Note
When running a console application from the debugger, it might automatically close the console window when the application ends, preventing you from seeing the output. To make the console application to wait until you press a key , call Console.ReadKey() or Console.Read() or Console.ReadLine() method at the end of the main method.



console applications console program what is console application console.writeline c# writeline console application in c# console application c# program sample console app c# console program