C# Interview

Memory Management & Modern C#

C# interview questions covering memory management & modern c#.

10 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

10 Results
71
Mid-LevelIntermediate

What is garbage collection in .NET?

Garbage collection is automatic managed-memory reclamation performed by the .NET Garbage Collector (GC). It identifies managed objects that are no longer reachable and can reclaim their memory.

72
Mid-LevelIntermediate

What are GC generations in .NET?

The .NET GC uses generations to optimize collection based on the observation that many objects have short lifetimes.

73
Mid-LevelIntermediate

What is IDisposable in C#?

IDisposable defines a Dispose method for deterministic cleanup of resources. It is commonly used by types that own unmanaged resources or other disposable resources.

74
Mid-LevelIntermediate

What is the using statement in C#?

The using statement ensures that an IDisposable object is disposed when execution leaves its scope, including when an exception occurs.

75
Mid-LevelIntermediate

What is the difference between Dispose and a finalizer?

Dispose provides deterministic cleanup and is called explicitly, usually through a using statement or declaration.

76
Mid-LevelIntermediate

What is a nullable value type in C#?

Normal value types such as int, bool, and DateTime cannot represent null. Nullable<T>, commonly written with the ? syntax, allows a value type to contain either a normal value or null.

77
Mid-LevelIntermediate

What are nullable reference types in C#?

Nullable reference types are a compile-time analysis feature that helps detect possible null-reference problems.

78
Mid-LevelIntermediate

What is a record in C#?

A record is a type designed primarily for data-centric models and provides value-based equality by default.

79
Mid-LevelIntermediate

What is the difference between class, struct, and record in C#?

A class is a reference type and normally uses reference-based equality unless equality is customized. It is appropriate for entities and objects with identity, mutable state, inheritance, or complex behavior.

80
Mid-LevelIntermediate

What are init-only properties and the required modifier in modern C#?

An init accessor allows a property to be assigned during object initialization but prevents normal reassignment afterward. This supports immutable-style object models.