Posts

Showing posts with the label c# 11

Raw String Literals In C# 11

  What is C# 11.0? C# 11.0 is the latest version of the C# language. Features Raw string literals Generic math support Generic attributes UTF-8 string literals etc Introduction Raw string literals in C# 11 are a new feature for developers to create strings that are easier to read and write and manipulate. Raw string literals comprise a sequence of characters enclosed in double quotes, but the 'at' character (@) comes before the opening quotes, making them readable even if they contain special characters or spaces. Traditional strings In traditional strings, special characters like the newline (\n) or the tab (\t) must be represented by escape sequences. If you wanted to create a string that contains the word "Hello" followed by a newline character, you would typically write: string message = "Hello\nWorld" ; C# Copy Raw string literals With raw string literals, using special characters like the traditional method is no longer necessary. Using raw string li