C# Flashcards

1
Q

When should you use a decimal type?

A

Anything representing base 10 numbers - eg Currency

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

When should you use a double type?

A

Always use double unless you need the base 10 accuracy that decimal offers (eg Currency).

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

static properties are per ?????? not per ??????

A

Static properties are per OBJECT not per INSTANCE

Therefore if a static property is changed in one instance, it will change across every instance of that object

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

A ?????? property allows instances of the same object to share data

A

A STATIC property allows instances of the same object to share data

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

What is the format of a double?

A

double d = 1D;

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

What is the format of a decimal?

A

decimal d = 1.0M;

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

What is the value of a?

x = 8;

y = 4;

z = 2;

a = x / y / z;

A

a = 1

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

What is the ?? operator used for?

A

Similar to Nz in VB, the ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.

eg

int? x = null;

y = x ?? 2;

y will be equal to 2

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

Use an array to split the following string into sections:

string input = “1 3 5 7”;

A

string[] values = input.Split(‘ ‘);

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