The Type System Flashcards

1
Q

Does every variable and constant have a type?

A

Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Does every expression have a type?

A

Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What information can be stored in a type?

A

Storage space, maximum and minimum, members, base type, interfaces it implements, and permitted operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the compiler do with the type information when creating the executable?

A

It stores it as metadata that’s later used by the CLR to guarantee type safety.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Common Type System (CTS)?

A

The fact that all types inherit from a common type, that for C# is System.Object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are value types?

A

Types derived from System.ValueType, these types directly contain their data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which are the value type categories?

A

structs and enums

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Are value types sealed? What implies for a value type to be sealed?

A

Yes, it means that a type can’t derive from a value type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are reference types?

A

Types that hold references to an object stored in the heap, this reference might be null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which are the reference types?

A

Classes, interfaces, and delegates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are literal types?

A

Types that appear literally, like 5.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you alter the type of a numeric literal?

A

With suffixes, like f, that are used for floats, like 3.33f.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you get the type of a value?

A

With the GetType method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you make the type implicit in a variable declaration?

A

With the var keyword, the type is set at compile-time based on the assignment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you make value types nullable?

A

By appending a ? at the end of the type, like int?.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly