string is an immutable reference type. C# offers several literal forms: Form Example Use Regular "Line\n" escape sequences Verbatim @"C:\temp\file.txt" paths, regex — backslashes kept Interpolated
QuickDevGuide
quot;Hello {name}" formatting values Raw literal (C# 11) """{ "json": true }""" JSON, SQL, multi-line text without escaping Format specifiers {value:N2} number with 2 decimals · {value:C} currency · {value:P1} percent · {date:yyyy-MM-dd} · {value,10} right-align · {value,-10} left-align. Performance Use StringBuilder for loops, string.Join for collections, and StringComparison.OrdinalIgnoreCase for culture-safe, case-insensitive comparisons.
Key Takeaways
Strings are immutable; use StringBuilder in loops.
Interpolated strings support alignment and format specifiers.
Raw string literals (""") avoid escaping in JSON/SQL.
Use StringComparison.OrdinalIgnoreCase for case-insensitive checks.