← Back to C# Course | Chapter 2: Variables & Types | Lesson 5 of 7

The string Type

In this page:

  1. The string Type

The string Type

A string is an immutable sequence of characters, written with double quotes. Strings support concatenation with +, interpolation with $"...", and a rich set of built-in methods. Because strings are immutable, every "modification" actually creates a new string.

Note: Prefer string interpolation ($"Hello {name}") over concatenation for readability.

Example: The string Type

markup
using System;

class Program
{
    static void Main(string[] args)
    {
        string first = "Ada";
        string last = "Lovelace";
        string full = first + " " + last;
        string greeting = $"Hello, {full}!";

        Console.WriteLine(full);
        Console.WriteLine(greeting);
        Console.WriteLine(full.Length);
        Console.WriteLine(full.ToUpper());
    }
}
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.