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

StringBuilder and why it exists 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 new StringBuilder object.

C Sharp (C#)
var sb = new [1]();
Drag options to blanks, or click blank then click option'
AStringBuilder
BString
CList
DStringBuilderBuilder
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'String' instead of 'StringBuilder' because strings are immutable.
Trying to use a non-existent class like 'StringBuilderBuilder'.
2fill in blank
medium

Complete the code to append text to the StringBuilder.

C Sharp (C#)
sb.[1]("Hello");
Drag options to blanks, or click blank then click option'
AInsert
BAppend
CAdd
DConcat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Add' which does not exist for StringBuilder.
Using 'Concat' which is a string method, not StringBuilder.
3fill in blank
hard

Fix the error in the code to convert StringBuilder to string.

C Sharp (C#)
string result = sb.[1]();
Drag options to blanks, or click blank then click option'
AToString
BtoString
CConvert
DStringify
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'toString' which causes a compile error.
Trying to use 'Convert' or 'Stringify' which do not exist.
4fill in blank
hard

Fill both blanks to create a StringBuilder and append text.

C Sharp (C#)
var sb = new [1]();
sb.[2]("World");
Drag options to blanks, or click blank then click option'
AStringBuilder
BString
CAppend
DAdd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'String' instead of 'StringBuilder' for the object.
Using 'Add' instead of 'Append' to add text.
5fill in blank
hard

Fill all three blanks to create a StringBuilder, append text, and convert to string.

C Sharp (C#)
var sb = new [1]();
sb.[2]("Hello ");
sb.[3]("World");
string result = sb.ToString();
Drag options to blanks, or click blank then click option'
AStringBuilder
BAdd
CAppend
DInsert
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Add' which is not a StringBuilder method.
Using 'Insert' which inserts at a position, not appends.