Strings and Interpolation
Compose and inspect text with modern C# string features.
Introduction
Strings are immutable reference types with rich formatting and search operations.
Interpolation inserts expressions inside braces. Trim returns a new string and does not mutate the original value.
Runnable C# example
Program.cs
using System;
class Program
{
static void Main()
{
string name = " Ada Lovelace ";
string clean = name.Trim();
Console.WriteLine($"{clean} has {clean.Length} characters.");
Console.WriteLine(clean.Contains("Love", StringComparison.OrdinalIgnoreCase));
}
}
Ada Lovelace has 12 characters.
TruePractice with the debugger
Set a breakpoint on an important assignment or condition, click Debug, and inspect the local values before stepping to the next line.
Practice with a challenge
Use what this lesson covers to solve a real problem. Each challenge runs in your browser with instant tests and an AI review.
- Reverse a String Return the characters of a string in reverse order. Easy
- Title Case Capitalize the first letter of every word. Easy
- Acronym Generator Create an acronym from the first letter of every word, in uppercase. Easy