C# Flashcards

1
Q

True or false: You can convert a bool to an int

A

False

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

Which type of object holds the actual data?

A

Value

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

Which type of object holds only a reference to the data?

A

Reference

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

How do you create a nullable value type?

A

Appending a ? to the

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

What can you do to reduce the amount of code you have to write when using a namespace?

A

Add the using keyword with the namespace as a top-level statement.

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

Can an abstract class be instantiated?

A

No

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

What makes a record different from a class is that the equality between objects means…

A

All of the types, properties and field values match.

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

Equality between two class objects means…

A

The two objects are the same object.

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

C# does not allow multiple inheritance. What can you use to mimic that behavior?

A

Interface

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

C# delegates is what and how do they compare to JS callbacks?

A

It is a type that stores a function pointer. It can be used to create callbacks but is not its only function.

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

Converting from a value type to a reference type is called…and conversion is…

A

Boxing

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

Converting from a reference type to a value type is called…and conversion is…

A

Unboxing explicit conversion (cast)

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

The main difference between string and stringbuilder is what? When would you use one over the other?

A

if a string is changed it creates a new instance whereas stringbuilder modifies the same instance. Use stringbuilder when performance is favored. (Large loops)

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

What is a sealed class?

A

A class that can not be inherited from.

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

What is a partial class?

A

A class that is defined into segmented parts within the same file or different files.

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

A constant can never be changed, when can a readonly be changed?

A

Only in a non-static constructor.

17
Q

When does a ref get initialized? When does an out?

A

Ref get’s initialized before a method gets called where an out get’s initialized within the method. out for out only

18
Q

Extension methods are a way to add to what?

A

An existing class library without modifying the original type definition class. Ex. Adding a method to the int class.

19
Q

Early Binding Polymorphism has the overridden methods where? What conditions must be met?

A

In the same class definition. It is required that the methods have different signatures such as different number of parameters or different order of parameters.

20
Q

Late Binding Polymorphism has the overridden methods where? What conditions must be met?

A

In the inherited classes. We would declare the method as virtual and override them in any way we want to in the inherited class. The signatures can be identical in this case.

21
Q

What makes an indexer different from a property?

A

Indexers use the this keyword so that the object can be treated as an array. (From my understanding, creating a property that has an array type adds one word to code so this is kind of dumb)

22
Q

Name the three main access modifiers.

A

public, private, protected

23
Q

What is the most basic definition of serialization?

A

Converting an object to a stream of bytes.

24
Q

What is a simple way to describe a jagged array?

A

An array of arrays.