Online C# Compiler
Introduction to C#
C# (pronounced "C sharp") is a modern, object-oriented, and type-safe programming language. Developed by Microsoft, it runs on the .NET ecosystem and is used for building desktop apps, web backends, and games using the Unity engine.
C# compiles source code into Common Intermediate Language (IL), which is then compiled into native machine code at runtime by the Common Language Runtime (CLR) Just-In-Time (JIT) compiler.
Features:
- Strongly typed, compiled language.
- Garbage collection for automatic memory management.
- Rich classes and system assembly collection.
C# supports modern features like properties (which encapsulate fields), delegates (type-safe function pointers), and events, making it a highly structured and developer-friendly language.
C# Properties
C# properties utilize shorthand getter/setter syntax to protect local member fields while exposing clean accessors for object instantiation.
csharp
using System;
class User {
public string Name { get; set; } = "Unknown";
}
class Program {
static void Main() {
User u = new User { Name = "Charlie" };
Console.WriteLine("User: " + u.Name);
}
}
csharp
using System;
class Program {
static void Main() {
Console.WriteLine("C# compiler initialized in .NET environment.");
}
}