0
0
C Sharp (C#)programming~5 mins

Common string methods in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AStartsWith()
BEndsWith()
CContains()
DIndexOf()
What does "Hello World".IndexOf("World") return?
A0
B6
C-1
D11
Which method removes spaces only from the start and end of a string?
ARemove()
BReplace()
CTrim()
DSplit()
If you want to change all 'a' characters to 'o' in a string, which method do you use?
AReplace('a', 'o')
BRemove('a')
CInsert('o')
DSubstring('a', 'o')
What will "Example".ToLower() return?
A"ExAmPlE"
B"EXAMPLE"
C"Example"
D"example"
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.