Now that Visual Studio is installed, let's create a simple console application.
Open Visual Studio:
- Launch Visual Studio from the Start menu.
Create a New Project:
- Click on "Create a new project" on the start page.
Choose Project Type:
- In the "Create a new project" dialog, select "Console App" under the "C#" category.
- Choose the appropriate framework version. For beginners, .NET Core is recommended.
- Click "Next."
Configure Project:
- Enter a name for your project (e.g., "HelloWorldApp").
- Choose a location to save your project.
- Click "Create."
Write Your First Code:
- Visual Studio will create a basic console application for you.
- Open the
Program.cs
file in the editor. - You'll see a
Main
method. Add the following code inside it: - using System; class Program { static void Main() { Console.WriteLine("Hello, C#! Welcome to your first program."); } }
Run Your Program:
- Press
F5
or click the "Start Debugging" button (green arrow) to build and run your application. - You should see the output in the console window: "Hello, C#! Welcome to your first program."
- Press
Congratulations! You've created and run your first C# program.