👉 Full lesson with practice questions on DevLadder (free, lesson 2 of 11 in the .NET Internals: CLR, CTS, CLS, IL, JIT, Memory Management & Garbage Collection course)
CLR responsibilities:
| Component | Job |
|---|---|
| Class loader | Loads assemblies and types, builds MethodTables |
| JIT compiler | IL → native code |
| Garbage collector | Allocates and frees managed memory |
| Type checker / verifier | Type safety: no invalid casts or reading random memory |
| Exception manager | Structured exception handling across frames and languages |
| Thread support | Managed threads, thread pool, synchronisation |
| Security | Type safety, (Framework: Code Access Security, removed in Core) |
| Interop | P/Invoke, COM interop, marshalling |
| Debugging / profiling APIs | Debuggers, profilers, diagnostics |
CTS: the type system all languages share:
System.Object ├── Value types (System.ValueType): int, double, bool, char, decimal, DateTime, struct, enum (System.Enum) └── Reference types: class, string, array (System.Array), delegate (System.Delegate), interface, record The CTS defines visibility (public, private, internal, protected), inheritance rules (single class inheritance, multiple interfaces), members (fields, methods, properties, events) and how values are boxed. Because C# int and VB.NET Integer are both System.Int32, the languages interoperate perfectly.
CLS: the common subset for cross-language libraries. Examples of non-CLS-compliant features: unsigned types in public APIs (uint: VB.NET historically lacked them), names differing only by case (Name and name: VB.NET is case-insensitive), pointers. Mark libraries with [assembly: CLSCompliant(true)] and the compiler warns about violations.
Interview questions on .NET Internals
What is the CLR and what does it do?
The Common Language Runtime is .NET's execution engine. It loads assemblies, verifies type safety, JIT-compiles IL to native code, manages memory with the garbage collector, handles exceptions, threads and synchronisation, provides interop with native code and exposes debugging/profiling services. Code running under it is "managed code".
What are CTS and CLS?
CTS (Common Type System) defines how types are declared and used in .NET: value vs reference types, inheritance, members, visibility, so all languages share one type system (C# int = VB.NET Integer = System.Int32). CLS (Common Language Specification) is a subset of CTS rules that every .NET language supports, so a CLS-compliant library can be used from any language (e.g. avoid public unsigned types or names differing only in case).
What is IL (MSIL/CIL) and what does the JIT do?
IL is the CPU-independent, stack-based intermediate code the C#/VB.NET compilers produce, stored with metadata in assemblies. At runtime the JIT compiles each method's IL to native machine code on its first call, optimised for the actual CPU; tiered compilation starts with quick code and re-compiles hot methods with full optimisation. ReadyToRun and Native AOT precompile to reduce startup time.
Read the full lesson with progress tracking and the rest of the course on DevLadder: free step-by-step tutorials and interview questions for developers.
Next in the course: Compilation: Roslyn, IL, JIT, tiered compilation, ReadyToRun and Native AOT →
