LyraLearn AI Learning Platform
Exams
← Module 2 Β· C# and Runtime Questions
🎧 Listen

Modern Language Questions

Every loop includes some form of "What's new in C# that you actually use?" It's not a changelog quiz β€” it's a currency check: do you still learn, and do you adopt features for reasons? The failing answer lists five features with no opinions. The passing answer picks three or four, says why each earns its place, and names one you deliberately don't use.

Records vs classes β€” the modeling question

"When do you reach for a record?" Headline: records give value-based equality, concise positional syntax, and non-destructive mutation via with β€” so they fit data that is defined by its contents: DTOs, API responses, query results, messages. public record TranscriptDto(int Id, string Status); is a complete type. The predictable follow-up: "So should entities be records?" No β€” EF entities are identity-based and mutated by change tracking; value equality on a mutable tracked object invites subtle bugs. "Records for data-shaped types, classes for identity and behavior" is the sentence to have ready.

Nullable reference types β€” discipline, not syntax

"Your projects have NRT enabled. What does it actually buy you?" Strong answer: it turns "might be null" into a compiler-checked contract β€” string? is an honest signature, string is a promise. Then the seniority markers: warnings are only as good as your honesty (the ! null-forgiving operator is a suppression, not a fix β€” grep for it in code review), and the compiler can't see across boundaries β€” model binding, JSON deserialization, and old libraries can still hand you null, so edges keep their guard clauses. That boundary caveat separates users from believers.

Primary constructors and pattern matching

Primary constructors (C# 12, on classes) exist in almost every current sample: public class ReviewService(IRepo repo, ILogger<ReviewService> log) β€” the DI ceremony collapses. Know one nuance: the parameters are captured, not automatically readonly fields, which is the mild controversy an interviewer may poke at.

Pattern matching is best presented through one honest example β€” a switch expression replacing an if/else ladder:

var route = status switch {
    ReviewStatus.Flagged => "queue/priority",
    ReviewStatus.Clean   => "archive",
    _                    => "queue/manual"
};

Say why: exhaustive, expression-shaped, no fall-through bugs. Property patterns (if (t is { Score: > 0.9, Reviewed: false })) earn a mention as cast-and-check killers.

Answering the currency question itself

Anchor to the job's floor β€” C# 12 here β€” then show headroom: collection expressions (int[] ids = [1, 2, 3];) at the floor; C# 13's params collections and Lock type, and C# 14's field keyword and extension members as "what I'd adopt where the target framework allows." Naming a feature you skip (e.g., "I avoid clever pattern-matching one-liners that juniors can't read") lands as judgment, and judgment is the score.

Practice prompts:

  1. Answer "records vs classes" in 90 seconds, ending with the entities follow-up pre-empted.
  2. Defend enabling NRT on a legacy codebase β€” including the migration cost.
  3. Give your personal three-feature answer to "what's new in C# that you actually use?"
🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.