Lesson 1 of 38 in the free C# Language — Basics to Advanced course on DevLadder.
C# is the language; .NET is the platform (runtime + base class library + SDK). You write C#, the compiler produces IL, and the .NET runtime executes it.
- CLR (Common Language Runtime): JIT, GC, type safety, exception handling, threading.
- BCL (Base Class Library):
System,System.Collections.Generic,System.IO,System.Net.Http, ... - CTS / CLS: the common type system that lets C#, F# and VB.NET interoperate.
// Program.cs — a complete program using top-level statements (C# 9+) Console.WriteLine("Hello, Divakar!"); var name = args.Length > 0 ? args[0] : "world"; Console.WriteLine($"Hello, {name}"); dotnet new console -n HelloApp cd HelloApp dotnet run -- Divakar Interview tip: "Managed code" = code whose execution is managed by the CLR (memory, security, exceptions). "Unmanaged code" = native code outside the CLR, e.g. Win32 DLLs called via P/Invoke.
Interview questions on C# Language
What is the difference between a value type and a reference type?
A value type variable holds the data itself (int, bool, decimal, DateTime, any struct/enum). Assigning it copies the value. A reference type variable holds a reference to an object on the managed heap (class, string, arrays, delegates, record). Assigning it copies the reference, so two variables can point to the same object.
var a = new List<int>(); var b = a; b.Add(1); // a.Count == 1 — same object int x = 1; int y = x; y++; // x is still 1 Value types are stored inline (stack for locals, inside the parent object for fields); reference-type objects always live on the heap and are cleaned up by the GC.
What is the difference between string and StringBuilder?
string is immutable: every concatenation creates a new string object, so building a string in a loop causes many allocations (O(n²) copying). StringBuilder keeps a mutable buffer and appends in place; call ToString() once at the end. Use StringBuilder for loops or many appends, plain strings/interpolation for a handful of pieces.
Explain const vs readonly vs static readonly.
-
const: compile-time constant, implicitly static, only primitives/strings; the value is baked into callers at compile time. -
readonly: instance field assigned at declaration or in a constructor; can differ per object. -
static readonly: one value per type, computed at runtime (e.g.static readonly HttpClient Client = new()).
Gotcha: if library A has public const int Max = 10 and app B uses it, changing it to 20 in A does nothing in B until B is recompiled. Use static readonly for values that may change.
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: First program, namespaces and keywords →

