Basic Flashcards
Sample questions for basic c#
What a tuple and why are they useful?
Tuples are used to store multiple items in a single variable. They are useful for returning multiple results from a function.
What is string builder and why is it used?
The string builder is a class of .NET to work with strings when repetitive operations are needed. It can improve the performance of code as it is faster than string
How can you prevent the silent overflow of integers?
It can be achieved via the project settings or by using checked()
What is a method body?
It contains the instructions that implement the method
When does the .NET garbage collector run? What does it do?
It is used to free memory space, it runs whenever the heap starts filling up
What is method overloading?
When multiple methods are created with the same name in same class but they work in different ways (different data types in method returns)
What is an Enum and why would you use it?
Enum is a special “class” that represents a group of constants. It makes values more readable making it less complex
What is casting?
When the datatype of a variable is changed.
What is an exception?
When a error occurs during the runtime.
What is meant by a “Strongly Typed Language”?
It is in which type of data is predefined as of the programming language and all constants or variables defined for the program must be assigned with one of these datatypes.
Why is c# described as memory safe?
C# supports static typing meaning that the language enforces type safety at compile time. It prevent a string type being interacted with as though it were an interger type
What is .NET?
.NET is an open source developer platform, it can build different types of applications and uses multiple languages.
What is a conditional breakpoint?
They allow you to break inside a code block when a defined expression evaluates to true.
In handling exceptions, when is the finally block run?
It always executes when try block exits.
In a method signature, what does the void keyword mean?
The void keyword indicates that this method has no return value
What is an out parameter?
The out parameter is used to pass arguements to methods by reference
What is the difference between an array and a list?
Lists are containers for elements having differing data types but arrays are containers for the same data type. New elements can be added to a list
What is the difference between a multidimensional array and a jagged array?
In a multidimensional array, each element in each dimension has the same size as the other elements in that dimension. In a jagged array, which is an array of arrays, each inner array can be of different size.
Which types of operator have the lowest priority?
Assignment (=, +=, -=, *=, /=, %=)
Which types of operator have the highest priority?
Postfix, increment and decrement (++,–)
What are method parameters passed by value?
Numeric types(integral and floating), char, bool, enum, struct.
What are method parameters passed by reference?
String, object, dynamic
What’s compile time and run time?
Compile time is the period when the programming code is converted to machine code. Runtime is the period of time the program is running.
Why is representing dates and times complicated?
Finding the difference between 2 dates is difficult. Leap year and formatting due different types display dates