Are User-Defined Literals Necessary in C#?

Published: (March 20, 2026 at 08:22 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to


โš ๏ธ Collection Error: Content refinement error: Error: 429 429 Too Many Requests: you (bkperio) have reached your weekly usage limit, upgrade for higher limits: https://ollama.com/upgrade


A Step Toward Meaningful Values

Conclusion

This is not a new idea. ๐Ÿ‘‰ It is a continuation of how C# has been evolving. Giving meaning directly to values is a natural evolution of C#. C# has been moving in this direction for years. This article proposes User-Defined Literals (UDL) as a natural var duration = 123;

We donโ€™t know: seconds?
milliseconds? No meaning. 123.Milliseconds()

Meaning depends on API. Traditionally, meaning is attached after the value is created. UDL shifts that boundary. Values themselves have no meaning. var duration = 123_ms;

Now: Type is known
Meaning is known Meaning is embedded in the value. C# has already evolved: foreach (pattern-based)
await (pattern-based)
using (pattern-based) Language privileges have been opened. See also:
https://dev.to/shimodateakira/why-c-keeps-opening-its-syntax-and-why-it-matters-3l7f) Literal = compile-time constant Not true. var s = $โ€œ{DateTime.Now}โ€;

Literal is syntax, not evaluation timing. APIs attach meaning later
Literals carry meaning immediately This is not syntax sugar. Itโ€™s a design shift. So the real question is: Should values themselves carry meaning? And if so: How far should C# go in that direction? Iโ€™m curious how others see this. Is this a natural evolution of C#, or are we just moving complexity from APIs into the language itself?

0 views
Back to Blog

Related posts

Read more ยป