Introduction to C#

Last Updated : 22 Apr, 2026

C# (C-sharp) is a modern, object-oriented language created by Microsoft in 2000 as part of the .NET framework. It is used to build Windows applications, web services and more. C# combines the power of C/C++ with the simplicity of Java and Visual Basic.

  • Used to build dynamic websites, RESTful APIs, and web services using frameworks like ASP.NET and ASP.NET Core.
  • Widely used in the Unity Engine, one of the most popular platforms for developing 2D, 3D, AR, and VR games.
  • Supports building Windows desktop applications using WPF and WinForms, as well as cross-platform mobile apps with Xamarin and .NET MAUI.
  • Commonly used for developing scalable cloud applications and enterprise software, especially on platforms like Microsoft Azure.

Basic C# Program

C#
using System;

namespace HelloGeeksApp{   
    class HelloGeeks{   
        static void Main(string[] args){
            Console.WriteLine("Hello Geek!");
        }
    }
}

Output
Hello Geek!

Structure of C# Program

The basic structure of a C# program defines the standard way every program must be written otherwise, it may result in errors or unexpected behavior during compilation or execution. The structure includes:

StructureofCSharpProgram
Structure of C# Program
  1. Namespace Import: using System; imports the System namespace, which provides fundamental classes such as Console class provides methods for standard input and output operations (such as reading from and writing to the console).
  2. Namespace Declaration: namespace HelloGeeksApp groups related classes together and helps organize code while avoiding naming conflicts.
  3. Class Declaration: class HelloGeeks defines a class that acts as a container for methods and program logic.
  4. Main Method: static void Main(string[] args) is the entry point of the C# program where execution begins. static means the method belongs to the class itself, and void indicates that it does not return any value.
  5. Statement: Console.WriteLine("Hello Geek!"); prints the text "Hello Geek!" to the console using the WriteLine method of the Console class.
  6. Braces { }: Curly braces define the beginning and end of code blocks such as namespaces, classes, and methods.

Frameworks and Technologies

C# works closely with the .NET ecosystem, which provides the runtime, libraries and tools for application development. Over time, several frameworks and technologies have evolved around C# to support diverse platforms.

6b41b46b-cc98-4102-a2b9-c4b5dfda6a0d
Frameworks and Technologies in C#
  • .NET Framework: The original Windows-only platform for building desktop and web applications. Commonly used for WPF, WinForms and ASP.NET applications.
  • .NET Core: Cross-platform, open-source version of .NET. Used to build apps that run on Windows, Linux and macOS. Supports web APIs, microservices and command-line tools.
  • .NET 5 and Later (.NET Unified Platform): Unifies .NET Framework and .NET Core into a single platform. Provides performance improvements and cross-platform support for all application types.
  • ASP.NET and ASP.NET Core: Frameworks for developing dynamic web applications, RESTful APIs and MVC-based web services.
  • Entity Framework Core (EF Core): Object-Relational Mapper (ORM) for database operations. Allows developers to interact with databases using C# objects instead of SQL queries.
  • Unity Engine: A game development platform that uses C# scripts for game logic. Powers 2D, 3D, AR and VR games across platforms like PC, consoles and mobile.

Advantages

  • Automatic garbage collection simplifies memory management.
  • Strong type system reduces runtime errors.
  • Large standard library and framework ecosystem.
  • Cross-platform support with modern .NET versions.
  • Excellent tooling in Visual Studio and .NET CLI.
Comment
Article Tags:

Explore