Programming foundations

Stage 1 · Lesson 3 of 9

Strings and interpolation

Your first language

A C# is : it never changes once made. So ToUpper(), Trim(), Replace() and Substring() return a new string and leave the original alone. Unlike Java, == on strings compares their contents, so name == "Ada" works as you expect.

Get one character with s[0] and the length with s.Length. Split text with Split(',') and join pieces with string.Join(", ", parts). Build output with string interpolation, as in $"{name} is {age}", which drops values straight into the text, rather than chains of +.

When you build a long string in a , use a StringBuilder, because each += creates a new string. string.IsNullOrWhiteSpace(input) is the quick check for empty input.

Common trapcalling name.Trim() without storing the result.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

  • GuideFree
    Learn C#

    Microsoft · Beginner

    Official C# fundamentals tutorials that you run locally with the .NET SDK

  • PlatformFree
    freeCodeCamp

    freeCodeCamp · Beginner

    Free Foundational C# certification, built with Microsoft, with a graded exam at the end

Practise

  • Small exercises in your language track, with free feedback from a human mentor

Keep handy

  • Quick C# syntax lookups with a try-it editor; not a replacement for the course

Mark this stage as not done?