Skip to content

C# Feature - Interpolated string handlers

Interpolated string handlers let an API control how interpolation is built, which can skip allocations when the consumer decides the message is not needed.

C# 10.0 (2021)

logger.LogDebug($"User {userId} loaded in {elapsedMs} ms");

The call-site syntax stays the same, but C# 10 lets the target API receive the interpolation through a custom handler instead of always building a string first.

  • This feature mainly matters for library and framework authors.
  • Most application developers use it indirectly through logging and diagnostics APIs.