C# source compiles to IL (Intermediate Language) packaged in assemblies (DLLs). The CLR (Common Language Runtime) JIT-compiles hot IL to native code, manages memory with garbage collection, and provides type safety—similar in role to the JVM for Java.
Key pieces
- .NET SDK — compiler, CLI (
dotnet), templates, and runtime for development - .NET Runtime — executes published apps in production (smaller than full SDK)
- NuGet — package manager for libraries (like npm or Maven Central)
- Target framework moniker — e.g.
net8.0in the.csprojfile
Build-run flow (web app)
dotnet new web -n MyAppscaffolds a projectdotnet buildcompiles C# to ILdotnet runstarts Kestrel and loads middleware pipelinedotnet publishproduces deployable output for containers or IIS
Important interview questions and answers
- Q: CLR vs JVM?
A: Both run managed bytecode/IL with GC and JIT; ecosystems differ—.NET is Microsoft-centric with C#/F#, JVM hosts Java/Kotlin/Scala. - Q: What is IL?
A: Intermediate Language—CPU-neutral instructions the runtime compiles to native code. - Q: SDK vs runtime in Docker?
A: Multi-stage builds use SDK image to build, slim runtime image to run—smaller attack surface.
Self-check
- Which CLI command compiles a .NET project?
- What package manager does .NET use?
Interview prep
- SDK vs runtime in Docker?
Multi-stage builds use the SDK image to compile and a slim runtime image to run—smaller attack surface and faster deploys.