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

Why string handling matters in C Sharp (C#) - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a string variable named greeting.

C Sharp (C#)
string greeting = [1];
Drag options to blanks, or click blank then click option'
A12345
B"Hello, world!"
CHello, world!
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the double quotes around the text.
Using single quotes which are for characters, not strings.
2fill in blank
medium

Complete the code to get the length of the string stored in name.

C Sharp (C#)
int length = name.[1];
Drag options to blanks, or click blank then click option'
ALength
Blength()
Ccount
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using length() with parentheses which causes an error.
Using lowercase 'length' which is not recognized.
3fill in blank
hard

Fix the error in the code to convert the string input to uppercase.

C Sharp (C#)
string upper = input.[1]();
Drag options to blanks, or click blank then click option'
AToUpper
Btoupper
CToLower
Dtouppercase
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase method names which do not exist.
Confusing ToUpper with ToLower.
4fill in blank
hard

Fill both blanks to create a substring from index 2 with length 4.

C Sharp (C#)
string part = text.[1](2, [2]);
Drag options to blanks, or click blank then click option'
ASubstring
BSubstr
C4
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Substr' which is not a C# method.
Confusing the length argument with the end index.
5fill in blank
hard

Fill all three blanks to check if the string message contains 'hello' ignoring case.

C Sharp (C#)
bool containsHello = message.[1]("hello", [2].[3]);
Drag options to blanks, or click blank then click option'
AContains
BStringComparison
COrdinalIgnoreCase
DEquals
Attempts:
3 left
💡 Hint
Common Mistakes
Using Equals instead of Contains for substring check.
Not passing the StringComparison argument, so case is considered.