C# Programming Introduction

Beginner
6 min read
Updated: Oct 2026
C# tutorial

What Is C#?

C# (pronounced “C sharp”) is a modern, multi-paradigm programming language from Microsoft. It is type-safe, object-oriented, and runs on .NET—used for web APIs, desktop apps, games (Unity), cloud services, and mobile apps.

Remember
C# program shape:
  using System;
  class Program {
    static void Main() { ... }
  }

Runs on:  .NET (cross-platform)
Created:  2000 by Anders Hejlsberg / Microsoft
Style:    compiled, managed, object-oriented

The C# compiler (Roslyn) and .NET runtime are open source under the .NET Foundation. This page is the gateway to the C# tutorial—practice topics such as strings, patterns, and interview programs have their own pages.

Why Learn C#?

C# pairs clear syntax with a large ecosystem. It is a strong first language and a practical choice for professional .NET work.

ReasonWhat you gain
Beginner-friendlyClear syntax, helpful compiler errors, and great tooling (VS / VS Code)
One language, many appsWeb, desktop, games, cloud, and mobile share the same C# skills
Modern featuresLINQ, async/await, properties, and a rich standard library
Cross-platform.NET runs on Windows, Linux, and macOS

Short history

MilestoneYearNotes
C# 1.02000–2002Designed by Anders Hejlsberg; shipped with .NET Framework
.NET Core2016Cross-platform, open-source runtime
.NET 5+2020+Unified platform; C# keeps evolving with new language versions
Roslyn—Open-source C# / VB compilers used by modern .NET

How a C# Program Is Structured

Console apps start in Main (or top-level statements in modern templates). Learn these parts once and reuse them everywhere.

PartRole
using System;Imports namespaces so you can use Console without a long name
class ProgramA type that holds your methods (entry point lives here in classic style)
static void Main()Program entry point — .NET starts here
Console.WriteLine(...)Writes a line of text to the console
Statements ending in ;Each instruction needs a semicolon

Cheat sheet — first syntax

GoalPattern
Print textConsole.WriteLine("Hello");
Integer variableint age = 20;
Read a linestring? line = Console.ReadLine();
Parse an intint.TryParse(line, out int n)
Conditionif (x > 0) { ... }
Counted loopfor (int i = 0; i < n; i++) { ... }

Your First C# Program — Hello World

Classic console style with an explicit Main method. Put this in Program.cs (or replace the template content).

C#
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, World!");
    }
}

How It Works

1. Import System. using System; lets you write Console instead of System.Console.

2. Enter Main. .NET calls Main when the program starts.

3. Print. Console.WriteLine writes the string and a newline to the console.

How to Create and Run a Console App

Install the .NET SDK, then use the dotnet CLI. You do not need Visual Studio to get started.

terminal
dotnet new console -n HelloApp
cd HelloApp
dotnet run
CommandMeaning
dotnet new consoleCreate a new console project
dotnet runBuild and run the current project
dotnet buildCompile without running
dotnet --versionCheck that the SDK is installed

Modern templates may use top-level statements (no explicit Main). The idea is the same: statements run from top to bottom when you call dotnet run.

Core Building Blocks

You do not need to master everything today. This map shows the main ideas you will meet as you continue with C#.

ConceptWhat it does
Variables & typesStore data (int, string, bool, …)
OperatorsArithmetic, comparison, and logical operations
Control flowif, else, switch for decisions
Loopsfor, while, foreach for repetition
MethodsReusable blocks with parameters and return values
StringsText data and common string methods
Classes & objectsGroup data and behavior in custom types
Collections & LINQLists, dictionaries, and query-style operations

Where Is C# Used?

Common places you will see C# in the real world:

Use caseWhy C# fits
Web APIs & ASP.NETStrong framework support for backends and services
Desktop appsWPF, WinForms, and cross-platform UI options
Games (Unity)Unity’s primary scripting language is C#
Cloud & AzureFirst-class tooling for Microsoft cloud services
Mobile (.NET MAUI)Share C# code across Android and iOS
Learning & interviewsPatterns and classic programs build problem-solving skill

Key Takeaways

  • C# is a modern, object-oriented language that runs on .NET.
  • Shape: using + class + Main + Console.WriteLine.
  • Run: dotnet new console, then dotnet run.
  • Next: practice strings and pattern programs to build fluency.

One line: write Main, print with Console.WriteLine, run with dotnet run — then practice with star patterns.

Frequently Asked Questions

C# (pronounced "C sharp") is a modern, multi-paradigm language from Microsoft. It is type-safe, object-oriented, and runs on .NET. Developers use it for web APIs, desktop apps, games with Unity, cloud services, and mobile apps with .NET MAUI.
Yes. C# has clear syntax, helpful compiler messages, and strong tooling in Visual Studio and VS Code. It teaches object-oriented concepts while staying approachable. Many courses use C# for first-year programming.
Install the .NET SDK, then run: dotnet new console -n HelloApp, cd HelloApp, and dotnet run. Put your code in Program.cs. Online C# runners work if you cannot install the SDK yet.
Yes. The C# compiler (Roslyn), the .NET runtime, and much of the platform are open source. Microsoft and the community maintain them on GitHub through the .NET Foundation.
Practice variables, if-else, loops, and methods in small console programs. Then learn classes, collections, exceptions, and LINQ. Use the pattern and interview programs on CodeToFun to build fluency.
Both are object-oriented and run on managed runtimes (.NET vs JVM). Syntax is similar. C# adds features such as properties, LINQ, and async/await with slightly different keywords, and integrates tightly with Azure while remaining cross-platform via .NET.

Did you know?

C# runs on .NET. Start a console app with dotnet new console, then dotnet run. The compiler (Roslyn) and runtime are open source under the .NET Foundation.

Next: C# Star Patterns

Turn nested loops into clear, printable patterns — a great next practice step.

Star patterns →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful