C# Programming Language
C# (C-Sharp) is a modern, object-oriented programming language
developed by Microsoft as part of the .NET initiative. First introduced in
2000, it's standardized by ECMA and ISO. C# is designed for the
Common Language Infrastructure (CLI). Let's explore the basics of C#!
C# Syntax and Structure
Familiar Syntax Code Structure
C# syntax is similar to C, C++, and Java. This makes it • Uses curly braces `{}` to define code blocks.
familiar to many developers. It's a case-sensitive language. • Statements end with semicolons `;`.
Example: Console.WriteLine("Hello, World!");
Key Features of C#
Object-Oriented Type Safety Memory Management
C# supports OOP principles: Strong static typing prevents Automatic garbage collection
encapsulation, inheritance, runtime errors. This leads to more manages memory efficiently. This
polymorphism. These principles robust and predictable reduces the risk of memory leaks.
promote code reusability and applications.
maintainability.
C# and .NET
.NET Framework .NET Core (.NET) CIL
Original execution environment, Cross-platform, open-source C# code compiles to Common
primarily for Windows. successor to .NET Framework. Intermediate Language (CIL).
CLR
CIL is executed by the Common
Language Runtime (CLR).
Practical Applications of C#
Desktop Apps Web Applications
WPF and WinForms are used for Windows desktop ASP.NET and ASP.NET Core are used for web
applications. development.
Game Development Mobile Apps
Unity game engine leverages C# for game logic. Xamarin allows cross-platform mobile app development.
Simple Console App
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}