DevAcademia
C++C#CPythonJava
  • C# Basics

  • C# Introduction
  • C# Get Started
  • C# Syntax
  • C# Output
  • C# Comments
  • C# Variables
  • C# Data Types
  • C# Type Casting
  • C# User Input
  • C# Operators
  • C# Math
  • C# Strings
  • C# Booleans
  • C# If...Else
  • C# Switch Statement
  • C# While Loop
  • C# For Loop
  • C# Break and Continue
  • C# Arrays
  • C# Files
  • C# OOP

  • C# OOP Introduction
  • C# Classes and Objects
  • C# Class Members
  • C# Constructors
  • C# Destructors
  • C# Access Modifiers
  • C# Properties
  • C# Inheritance
  • C# Polymorphism
  • C# Abstraction
  • C# Interfaces
  • C# Enums
  • C# Exceptions
  • C# Quizzes

  • C# Quiz Introduction
  • C# Basics

  • C# Introduction
  • C# Get Started
  • C# Syntax
  • C# Output
  • C# Comments
  • C# Variables
  • C# Data Types
  • C# Type Casting
  • C# User Input
  • C# Operators
  • C# Math
  • C# Strings
  • C# Booleans
  • C# If...Else
  • C# Switch Statement
  • C# While Loop
  • C# For Loop
  • C# Break and Continue
  • C# Arrays
  • C# Files
  • C# OOP

  • C# OOP Introduction
  • C# Classes and Objects
  • C# Class Members
  • C# Constructors
  • C# Destructors
  • C# Access Modifiers
  • C# Properties
  • C# Inheritance
  • C# Polymorphism
  • C# Abstraction
  • C# Interfaces
  • C# Enums
  • C# Exceptions
  • C# Quizzes

  • C# Quiz Introduction

Loading Cs tutorial…

Loading content
C# BasicsTopic 2 of 55
←PreviousPrevNextNext→

Download and Install .NET SDK

To start programming in C#, you need to install the .NET Software Development Kit (SDK): 1. Visit the official Microsoft website: https://dotnet.microsoft.com/download 2. Download the latest .NET SDK for your operating system (Windows, macOS, or Linux) 3. Run the installer and follow the installation instructions 4. Verify the installation by opening a command prompt or terminal

Verify Installation

Open your command prompt or terminal and type: `dotnet --version` This should display the installed .NET version.

Example
// Check .NET version
dotnet --version
Output
6.0.100

Your First C# Program

Let's create a simple 'Hello World' program: 1. Create a new console project using `dotnet new console -n HelloWorld` 2. Navigate to the project directory 3. Run the program using `dotnet run`

Example
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
        }
    }
}
Output
Hello, World!

Understanding the Structure

• `using System;`: Imports the System namespace • `namespace HelloWorld`: Declares a namespace for organizing code • `class Program`: Defines a class (the filename doesn't need to match) • `static void Main(string[] args)`: The main method - entry point of C# programs • `Console.WriteLine()`: Prints output to the console • Curly braces `{}`: Define code blocks • Semicolon `;`: Ends statements

Choosing an IDE

While you can use a text editor and command line, IDEs make development easier: - Visual Studio: Full-featured IDE for Windows - Visual Studio Code: Lightweight cross-platform editor with C# extensions - Rider: Cross-platform .NET IDE from JetBrains - Visual Studio for Mac: IDE for macOS development

Expected Output

Hello, World!
✅ Well done! You've successfully set up your C# environment and run your first program. In the next lessons, we'll dive into variables, data types, and control structures to build more complex applications.
C# BasicsTopic 2 of 55
←PreviousPrevNextNext→