Which of the following is a valid way to create an empty string in C#?
easy🧠 Conceptual Q1 of 15
C Sharp (C#) - Strings and StringBuilder
Which of the following is a valid way to create an empty string in C#?
Astring s = "";
Bstring s = null;
Cstring s = ' ';
Dstring s = new String();
Step-by-Step Solution
Solution:
Step 1: Understand empty string creation
An empty string is a string with zero characters, represented by double quotes "".
Step 2: Evaluate each option
string s = ""; correctly assigns an empty string. string s = null; assigns null, not an empty string. string s = ' '; uses single quotes which are for chars, not strings. string s = new String(); is invalid because String() constructor requires parameters.
Final Answer:
string s = ""; -> Option A
Quick Check:
Empty string = "" [OK]
Quick Trick:Use double quotes "" for empty strings in C# [OK]
Common Mistakes:
MISTAKES
Using single quotes for strings
Confusing null with empty string
Trying to use String() constructor without parameters
Master "Strings and StringBuilder" in C Sharp (C#)
9 interactive learning modes - each teaches the same concept differently