Company
Date Published
Author
Niels Swimberghe
Word count
2353
Language
English
Hacker News points
None

Summary

C# 11's Raw String Literals allow for a new way to generate TwiML in ASP.NET Core Minimal APIs. Unlike previous methods, Raw String Literals don't require XML escaping and can handle multi-line text with better formatting. The syntax involves starting and ending the string with at least three double quotes. This feature is still in preview but can be enabled by adding `<LangVersion>preview</LangVersion>` to the project file. It offers advantages such as easier formatting, reduced memory usage, and improved performance compared to using strings or the Twilio helper library. However, it also means that there's no compilation error checking, and XML escaping must still be handled manually for user input protection. The choice of method depends on the specific use case, with Raw String Literals being more suitable for simple cases and the Twilio helper library being better suited for complex scenarios.