Answer: C# uses automatic memory management via the .NET Garbage Collector (GC) . GC allocates objects on the managed heap . When objects become unreachable, the GC reclaims memory. Generational GC (Gen 0, Gen 1, Gen 2) improves performance by: Collecting short-lived objects more frequently. Promoting surviving objects to older generations. Best practices : Avoid large object allocations frequently. Use IDisposable and using for unmanaged resources. Avoid memory leaks by breaking references (especially in events).
Answer:
C# uses automatic memory management via the .NET Garbage Collector (GC).
Best practices:
IDisposableandusingfor unmanaged resources.