In C#, string is an immutable sequence of Unicode characters. It is an alias for System.String.
string name = "Alice";
string empty = "";
string nullStr = null;
// Verbatim string — backslashes are literal
string path = @"C:\Users\Alice\Documents";
// Multi-line verbatim
string multiLine = @"Line 1
Line 2
Line 3";
string firstName = "Alice";
int age = 30;
string msg = $"Hello, {firstName}! You are {age} years old.";
Console.WriteLine(msg); // Hello, Alice! You are 30 years old.
// Expressions inside {}
Console.WriteLine($"Next year: {age + 1}");
Console.WriteLine($"Upper: {firstName.ToUpper()}");
Console.WriteLine("Tab:\there"); // Tab: here
Console.WriteLine("New\nLine"); // new line
Console.WriteLine("Quote: \"hi\""); // Quote: "hi"
Console.WriteLine("Backslash: \"); // Backslash: \
string a = "hello";
string b = "HELLO";
Console.WriteLine(a == b); // false
Console.WriteLine(a.Equals(b, StringComparison.OrdinalIgnoreCase)); // true
Console.WriteLine(string.Compare(a, b, ignoreCase: true) == 0); // true