BCA / B.Tech 11 min read

How To Create a Console Application

How to Create Console Application in .NET in Hindi |  How to create a Console Application in Visual Studio 2008:

 
  • How to create, save, and run a Console Application in Visual Studio 2008
  • Visual Studio 2008 is a powerful IDE (Integrated Development Environment) based on the .NET Framework, which is used to develop various types of applications.
  • Creating Console and Windows Applications on Visual Studio 2008 .NET Framework is a simple process.
  • A console application is suitable for a text-based interface, while a window application provides a user-friendly graphical interface.
  • By following these steps, you can create your first .NET application and run it successfully.
Here we will explain in detail the process of creating, saving, and running a console application and a window application.

What is a console application?

A console application is an application that runs on a command-line interface (CLI). It mainly uses text-based input and output.

Creating, saving, and running a console application

Step 1: Open Visual Studio 2008

  • Open Visual Studio 2008 on your computer.
  • Go to the "File" menu and click on "New". Then choose the "Project" option.
Step 2: Create a new project

  • In the "New Project" dialog box, choose the "Visual C#" or "Visual Basic" option (based on your language preference).
  • Choose the "Console Application" template.
  • In the "Name" box, write the name of your project (e.g., MyFirstConsoleApp).
  • Under "Location", choose the folder where you want to save the project.
  • Click "OK".
Step 3: Write the code

  • Visual Studio will open a file (Program.cs or Module1.vb) for your new Console Application project.
The code for a simple "Hello World" program is given below:
C#:

using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
        Console.ReadLine(); // This line stops to let the user see the output
    }
}
VB.NET:

Module Module1
    Sub Main()
        Console.WriteLine("Hello World!")
        Console.ReadLine() ' This line stops the output screen
    End Sub
End Module

Step 4: Save the project

  • Go to the "File" menu and choose the "Save All" option.
  • Give a name to the project and save it in your preferred location.
Step 5: Run the project

  • To run the project, go to the "Debug" menu and choose the "Start Without Debugging" (Ctrl+F5) option.
  • The console screen will open and the output will be shown.
Output:

Hello World!

  • The screen will be held until you press any keyboard button.
  • How to create, save, and run a Windows Application

What is a Windows Application in .NET in Hindi | What is a Windows Application?

  • A Windows Application is an application that uses a GUI (Graphical User Interface).
  • It has buttons, text boxes, and other visual elements.
Creating, saving, and running a Windows Application:

Step 1: Open Visual Studio 2008

  • Open Visual Studio 2008.
  • From the "File" menu, choose the "New" and then "Project" option.
Step 2: Create a new project

  • In the "New Project" dialog box, choose "Windows Forms Application".
  • In the "Name" box, write the name of your project (e.g., MyFirstWindowsApp).
  • Click "OK".
Step 3: Design the GUI

  • A blank window will be shown in the Form Designer of Visual Studio.
  • Drag controls like buttons or text boxes from the "Toolbox" panel and drop them onto the window.
  • Use the "Properties" window to set the properties of each control.
Step 4: Write the code

  • Double-click on a button from the design view. This will open its Click event code in the window.
Example code:
C#:
private void button1_Click(object sender, EventArgs e)
{
    MessageBox.Show("Hello, this is my first Windows application!");
}
VB.NET:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    MessageBox.Show("Hello, this is my first Windows application!")
End Sub

Step 5: Save and run the project

  • Go to the "File" menu and choose "Save All".
  • To run the project, click on "Start Debugging" (F5).
  • The application will launch and you can run it.