A small but welcome quality of life improvement in C# 10. You can finally use string interpolation for `const` strings, as long as the inputs are also strings.
public class Routes
{
private const string ApiBase = "/api/v1";
// Before C# 10: Compile Error
// Now: Works!
public const string Users = $"{ApiBase}/users";
public const string Orders = $"{ApiBase}/orders";
}
This is fantastic for attributing Controllers or defining consistent routing constants without resorting to `static readonly`.
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.