C#-Grundlagen

Strings and Interpolation

Strings are immutable reference types with rich formatting and search operations.

How it works

Compose and inspect text with modern C# string features.

Interpolation inserts expressions inside braces. Trim returns a new string and does not mutate the original value.

Runnable C# example

C#
Run code →
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));
    }
}
Expected output
Ada Lovelace has 12 characters.
True

Practice 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.