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