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

String creation and literal types in C Sharp (C#) - Interactive Code Practice

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

Complete the code to create a string variable named greeting with the value "Hello".

C Sharp (C#)
string greeting = [1];
Drag options to blanks, or click blank then click option'
A"Hello"
B'Hello'
CHello
Dnew String("Hello")
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes for strings.
Not using quotes at all around the text.
2fill in blank
medium

Complete the code to create a verbatim string literal that includes a file path.

C Sharp (C#)
string path = [1];
Drag options to blanks, or click blank then click option'
A"C:\\Users\\Admin"
B"C:/Users/Admin"
C'C:\Users\Admin'
D@"C:\Users\Admin"
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes.
Not using @ and escaping backslashes manually.
3fill in blank
hard

Fix the error in the code to correctly create a string with a newline character.

C Sharp (C#)
string message = [1];
Drag options to blanks, or click blank then click option'
A"Hello\nWorld"
B'Hello\nWorld'
C"Hello\World"
D"Hello\rWorld"
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes for strings.
Using invalid escape sequences like \W.
4fill in blank
hard

Fill both blanks to create a string that contains a tab character and a double quote inside it.

C Sharp (C#)
string text = [1] + "\t" + [2];
Drag options to blanks, or click blank then click option'
A"Hello"
B'Hello'
C"\"World\""
D'\"World\"'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes for strings.
Not escaping double quotes inside strings.
5fill in blank
hard

Fill all three blanks to create a multi-line verbatim string that includes quotes and a newline.

C Sharp (C#)
string poem = [1] + "\n" + [2] + "\n" + [3];
Drag options to blanks, or click blank then click option'
A@"Roses are red,"
B"Violets are blue,"
C@"Sugar is sweet."
D"Sugar is sweet."
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes.
Not using @ for verbatim strings where needed.