We can prove that String is a class by looking up the String class documentation and trying some of the methods and properties listed there.

This example uses Length and Contains().

string s = "Hello World"; Console.WriteLine(s.Length); Console.WriteLine(s.Contains("o"));

We’ve already seen one static property Empty and one static method, IsNullOrEmpty():

string s = String.Empty; bool isEmpty = String.IsNullOrEmpty(s);



Let’s practice using Replace(String, String), which returns a new string with every instance of the first argument replaced by the second.

Replace all instances of "ollie" with "ana".

If you’re unfamiliar with Replace(), the documentation is your best friend.

Folder Icon

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Already have an account?