CategoriesCore OOP
Core OOP
4 features across 3 C# versions
C# 1.02002
Object-Oriented Foundation
Full object-oriented design featuring managed classes, structures, explicit interfaces, encapsulation, and runtime polymorphism.
1public interface IWorkable { void PerformWork(); }
2public class Developer : IWorkable {
3 public string Name { get; set; }
4 public void PerformWork() => Console.WriteLine(Name + " is coding.");
5}
C# 1.02002
Delegates and Events
Type-safe function pointers allowing operations to be cleanly executed dynamically via native observer/subscriber logic architectures.
1public delegate void WorkHandler(string msg);
2public class Project {
3 public event WorkHandler OnComplete;
4 public void Close() => OnComplete?.Invoke("Done!");
5}
C# 32007
Extension Methods
Enables developers to attach custom method interfaces onto pre-existing sealed object instances without altering their source base.
1public static class Extensions {
2 public static bool IsEven(this int num) => num % 2 == 0;
3}
C# 122023
Primary Constructors for Classes
Allows parameters to be captured directly along class headers, removing constructor boilerplate scripts.
1public class IdentityService(string secretKey, int timeoutSeconds) {
2 public bool CheckValid() => secretKey.Length > 0;
3}