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

Default values for types in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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#?
Anull
B' ' (space)
C'a'
D'\0' (null character)
Which of these types has a default value of null in C#?
Astring
Bbool
Cint
Ddouble
What does the expression default(bool) return?
Atrue
Bfalse
Cnull
D0
How do you get the default value of a generic type T in C#?
Adefault(T)
BT.default
Cnull
Dnew T()
What is the default value of a decimal type in C#?
A0.0
Bnull
C0
D0.0m
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.