Recall & Review
beginner
What does the
ToUpper() method do in C# strings?It converts all characters in the string to uppercase letters.
Click to reveal answer
beginner
How does the
Contains() method work on a string?It checks if a specified substring exists inside the string and returns
true or false.Click to reveal answer
beginner
What is the purpose of the
Trim() method?It removes all leading and trailing white spaces from the string.
Click to reveal answer
beginner
Explain what
Replace(oldValue, newValue) does in a string.It replaces all occurrences of
oldValue in the string with newValue.Click to reveal answer
intermediate
What does the
Substring(startIndex, length) method return?It returns a new string that starts at
startIndex and has the specified length.Click to reveal answer
Which method would you use to check if a string starts with a specific word?
✗ Incorrect
The
StartsWith() method checks if the string begins with the specified substring.What does
"Hello World".IndexOf("World") return?✗ Incorrect
It returns the starting index of the substring "World" which is 6.
Which method removes spaces only from the start and end of a string?
✗ Incorrect
Trim() removes whitespace from both the beginning and end of a string.If you want to change all 'a' characters to 'o' in a string, which method do you use?
✗ Incorrect
Replace() changes all specified characters to new ones.What will
"Example".ToLower() return?✗ Incorrect
ToLower() converts all letters to lowercase.Describe how you would check if a string contains a certain word and then replace it with another word.
Think about first finding the word, then changing it.
You got /4 concepts.
Explain the difference between
Substring() and Remove() methods in strings.One keeps a piece, the other cuts out a piece.
You got /4 concepts.