Locked lesson.
About this lesson
We examine various String Methods to modify string variables, including changing the case and replacing parts of the string.
Exercise files
Download this lesson’s related exercise files.
10 - String Methods.docx60.8 KB 10 - String Methods SOLUTION.docx
57.8 KB
Quick reference
String Methods
String methods allow us to do different things to our strings, programatically.
When to use
Use these methods as needed.
Instructions
string name = "john";
name.ToUpper(); // convert all characters to uppercase
name.ToLower(); // convert all characters to lowercase
name.Replace("Old Thing", "New Thing"); // Replace parts
name.GetType(); // Get data type
name.Trim(); // remove trailing and preceding spaces
Hints & tips
- name.ToUpper();
- name.ToLower();
- name.Replace("Old Thing", "New Thing");
- name.GetType();
- name.Trim();
Lesson notes are only available for subscribers.