C# Flashcards
When should you use a decimal type?
Anything representing base 10 numbers - eg Currency
When should you use a double type?
Always use double unless you need the base 10 accuracy that decimal offers (eg Currency).
static properties are per ?????? not per ??????
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
A ?????? property allows instances of the same object to share data
A STATIC property allows instances of the same object to share data
What is the format of a double?
double d = 1D;
What is the format of a decimal?
decimal d = 1.0M;
What is the value of a?
x = 8;
y = 4;
z = 2;
a = x / y / z;
a = 1
What is the ?? operator used for?
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
Use an array to split the following string into sections:
string input = “1 3 5 7”;
string[] values = input.Split(‘ ‘);