Recall & Review
beginner
What is the default value of an
int in C#?The default value of an
int is 0.Click to reveal answer
beginner
What is the default value of a
bool in C#?The default value of a
bool is false.Click to reveal answer
beginner
What is the default value of a reference type like
string in C#?The default value of a reference type such as
string is null.Click to reveal answer
intermediate
How can you get the default value of any type
T in C#?You can use the expression
default(T) to get the default value of type T.Click to reveal answer
beginner
What is the default value of a
double in C#?The default value of a
double is 0.0.Click to reveal answer
What is the default value of a
char in C#?✗ Incorrect
The default value of a
char is the null character '\0', which is the Unicode character with code zero.Which of these types has a default value of
null in C#?✗ Incorrect
Reference types like
string have a default value of null. Value types like int, bool, and double have non-null default values.What does the expression
default(bool) return?✗ Incorrect
default(bool) returns false, which is the default value for the bool type.How do you get the default value of a generic type
T in C#?✗ Incorrect
The correct way to get the default value of a generic type
T is to use default(T).What is the default value of a
decimal type in C#?✗ Incorrect
The default value of
decimal is 0. The suffix m is used for literals but not for default values.Explain what default values are in C# and give examples for both value and reference types.
Think about what happens when you declare a variable but don't assign a value.
You got /4 concepts.
How can you use the
default keyword with generic types in C#? Why is it useful?Consider how you write code that works with any type.
You got /3 concepts.