The Wayback Machine - https://web.archive.org/web/20251002150105/https://www.geeksforgeeks.org/c-sharp/introduction-to-c-sharp/
Open In App

Introduction to C#

Last Updated : 27 Sep, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

Features-csharp
C# Features

Why use C#?

  • Easy to learn: Clear, readable syntax, familiar to Java/C++ developers.
  • Object-Oriented: Supports OOP principles (encapsulation, inheritance, polymorphism).
  • Cross-platform: Build desktop, web, mobile, cloud and game applications.
  • Rich libraries & frameworks: Large .NET library for faster development.
  • Memory management: Automatic garbage collection reduces memory leaks.
  • Modern features: LINQ, async/await and other powerful tools.

Applications of C#

  • Windows Applications: Used to build desktop apps with frameworks like WPF and WinForms.
  • Web Applications & Services: Powers dynamic websites, APIs and services using ASP.NET / ASP.NET Core.
  • Game Development: Popular in Unity engine, one of the most widely used game development platforms.
  • Mobile Applications: Supports cross-platform apps with Xamarin and .NET MAUI.
  • Cloud & Enterprise Solutions: Widely used for scalable applications on Microsoft Azure and enterprise software.

Hello World Program in C#

C#
using System;

namespace HelloGeeksApp
{   
    class HelloGeeks
    {   
        static void Main(string[] args)
        {

            Console.WriteLine("Hello World");

            Console.ReadKey();
        }
    }
}

Explanation

  1. Program starts execution from the Main method.
  2. Console.WriteLine("Hello World"): prints "Hello World" on the console.
  3. Console.ReadKey(): waits for the user to press a key so the console window doesn’t close immediately.

Keywords

  • using: lets you use classes from a namespace without full names.
  • System: built-in namespace that has basic classes (like Console).
  • namespace: groups related classes together (like a folder).
  • class: defines a class (container for code).
  • HelloGeeks: name of your class.
  • static: method belongs to the class itself, no object needed.
  • void: return type meaning “no value returned”.
  • string[] args: stores command-line arguments (optional input).

Advantages of C#

  • Automatic garbage collection: reduces memory leaks and makes memory management easy.
  • Safe and low maintenance: reliable compared to many other languages.
  • Cross-platform via IL: compiled into Intermediate Language, independent of OS/architecture.
  • Easy to learn: clear syntax, familiar to Java/C++ programmers.
  • Rich standard library: many built-in classes and features.
  • Strongly typed: reduces errors and improves reliability.

Disadvantages of C#

  • Dependent on .NET Framework: less flexible outside it.
  • Slower performance: requires compilation after changes.
  • Mostly Microsoft-focused: limited in some non-MS contexts.
  • Garbage collection overhead: may affect performance.
  • Steeper learning curve: advanced concepts (like parallel processing) are harder.
  • Limited functional programming support: mainly object-oriented.

Related Articles


Article Tags :

Explore