What is defined as a set of contiguous data points of the same type?
An array
When an array is declared in C# and each index is not explicitly filled with a value, what is the value for the unset indexes?
The default value of the data type
What is the default value for a bool in C#?
false
What is an example of declaring an array in C# by specifying the total number of items in the array?
(Declare an array of 3 ints)
int[] myInts = new int[3];
What is an example of declaring an array using the C# array initialization syntax which specifies each array item?
(Declare an array with three bools--each false)
bool[] boolArray = { false, false, false };
What is an example of declaring an implicitly typed array in C#?
(Declare an array with 1, 10, 100, and 1000)
var a = new[] { 1, 10, 100, 1000 };
What is the base class to every type in C#, including the fundamental data types?
System.Object
What is the data type to declare an array with in C# if you want the subitems of the array to be any type?
System.Object
What is the term for an array of multiple dimensions where each row is of the same length?
A rectangular array
What is the term for an array of multiple dimensions where the inner arrays each may have a different length?
A jagged array
What is the property to return the number of items in an array in C#?
Length
What is the static Array method in C# to reverse the contents of a one-dimensional array?
Array.Reverse()
What is the difference between a method and function in C#?
A function returns a value to the caller
What are methods within methods called in C#?
Local functions
What in C# is a function declared inside another function that must be private and does not support overloading?
Local functions
Do local functions support nesting in C#?
Yes
What does it mean for a parameter to be sent into a function by value?
A copy of the data is passed in
What method can be called on a List<string> object in C# to convert it to an instance of string[] (an array of strings)?
ToArray()
Which of ? or : comes first in a ternary statement in C#?
?
What is the VS Code IDE recommended syntax for declaring an empty array of strings in C#?
Array.Empty<string>()
What is the default way a parameter is sent into a function in C#?
By value
(The reference is passed by value for reference types)
In C#, what are the two cases that relate to exactly what is copied when a parameter is sent into a function by value?
If the parameter is a value type or reference type
What is an enumerator in C#?
A class or structure that implements the IEnumerable interface
By convention, the suffix of an enum type name in C# is usually what?
Enum
What is the parameter modifier in C# to mark a parameter as an output parameter?
out
What is the well-known special case of a reference type in C# that is still passed by value?
string
What is a term for a temporary, dummy variable that is intentionally unused?
A discard
What is the parameter modifier you can use in C# if you want a method to be able to change the value of a passed in argument?
ref
What is the C# keyword that allows you to pass into a method a variable number of identically typed parameters as a single logical parameter?
params
What is a method called when there are multiple methods with the identical name but differ in the number or type of parameters?
Overloaded
What is the C# keyword for the custom data type of name-value pairs?
enum
What is the C# interface that objects must support to work with the foreach loop (and objects that do can be called enumerators)?
IEnumerable
What is the bitwise AND operator in C#?
&
What is the bitwise OR operator in C#?
|
What is the bitwise XOR operator in C#?
^
What is the ones' compliment operator in C# (that flips the bits)?
~
What did C# 6 introduce that can be used to shorten the syntax of defining single-line methods?
Expression-bodied members
What is one line of code showing a method that adds two ints together and returns an int using the expression-bodied member feature of C#?
static int Add(int x, int y) => x + y;
What is the left shift operator in C#?
<<
What is the right shift operator in C#?
>>
What does System.ValueType ensure about types derived from it in C#?
That they are allocated on the stack
What is a nullable type in C#?
A type that can be all of the values of its underlying type, and null
When does a value type variable die in C#?
When it falls out of scope
What types in C# are allocated on the stack?
Value types
What C# type has the purpose of overriding the virtual methods defined by System.Object to use value-based instead of reference-based semantics?
System.ValueType
What is the result of this (C#)?
0110 << 1
1100
What is the result of this (C#)?
0110 >> 1
0011
What is the result of this (C#)?
1100 & 0100
0100
What is the result of this (C#)?
0110 | 0100
0110
What is the result of this (C#)?
0110 ^ 0100
0010
What is a one-line way to throw an ArgumentNullException if the variable message was null in C#?
ArgumentNullException.ThrowIfNull(message);
What is the operator in C# to flip the bits of a binary number?
~
What is the result of this (C#)?
0011 ^ 1100
1111
What is the result of this (C#)?
0111 ^ 1011
1100
What is the ones' compliment of a binary number?
The value you get by flipping all the bits
Why can you not reassign a reference type argument to be a new object inside a method call in C#?
The reference is passed by value (it is a copy of the reference to the object)
If you want to reassign a reference to point to a new object inside a method call in C#, what parameter modifier must you use?
ref
What types in C# are allocated on the managed heap?
Reference types
A reference type in C# can inherit from any type except for what?
System.ValueType
When does a reference type variable die in C#?
When it is garbage collected
What values can a nullable bool have in C#?
true, false, or null
When using the ? suffix to use a nullable value type, this is really just shorthand for what type?
System.Nullable<T>
With the System.Nullable<T> structure type, what kind of types can be used as T?
Value types
What is an example of declaring a variable of a nullable int type in C#?
int? nullableInt = 10;
What is the null-coalescing operator in C# (for the benefit of a more compact version of a traditional if/else condition)?
??
Example:
int myData = dr.GetIntFromDatabase() ?? 100;
What is the null-coalescing assignment operator in C# (assigns the left-hand side to the right-hand side only if the left-hand side is null)?
??=
Example:
int? nullableInt = null;
nullableInt ??= 12;
What is an example using the null conditional operator in C# (Length property of args but do not throw an error if args is null)?
args?.Length
What light construct in C# provides a convenient way to return more than one value from a method?
Tuples
When a type in C# returns a tuple from a method in order to return out the class instance's individual properties, what is the method conventionally called?
Deconstruct()
What does C# support for the purpose of creating a set of symbolic names that map to known numerical values?
Enumerations
What does it look like to declare an enum EmpTypeEnum that uses byte as the storage value rather than an int in C#?
enum EmpTypeEnum : byte
What class type do .NET Core enumerations get functionality from?
System.Enum
What is the process of changing the implementation of a virtual (or abstract) method of a base class in a derived class in C# called?
Overriding
The <Nullable> node in a C# project file listing can be used to opt in or configure what?
Nullable reference types
With C# 10, are nullable reference types enabled or disabled by default?
They are enabled
How to declare a tuple called values in C# that has a string "a", an int 5, and a string "c" using the var keyword?
var values = ("a", 5, "c");
What type is this (C#)?
var values = ("a", 5, "c");
ValueTuple
What type of method parameters in C# must be assigned by the method being called (a compiler error occurs if the called method fails to assign it)?
Output parameters
Previous card
First card
Random order
Next card