WeCodeAcademy

C# Strings

ExampleC#
using System;

class Program
{
    static void Main()
    {
        string s = "Hello, C#";
        Console.WriteLine(s.Length);
        Console.WriteLine(s.ToUpper());
        Console.WriteLine(s.Substring(7));
        Console.WriteLine(s.IndexOf("C#"));
        Console.WriteLine(s.Replace("C#", "World"));
        Console.WriteLine(s.Contains("Hello"));
        Console.WriteLine(string.Join("-", new string[] { "x", "y", "z" }));
        Console.WriteLine("a,b,c".Split(',').Length);
        Console.WriteLine("  trim me  ".Trim() + "|");
    }
}
Output
9
HELLO, C#
C#
7
Hello, World
True
x-y-z
3
trim me|
Quick check

Which property gives the length of a string?

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.