C# Flashcards
(37 cards)
What does async and await mean?
They are code markers, that tell us where the application should continue once the task is complete.
Await, wait here until this line of code is complete.
In a synchronous application if code is blocked then the entire application waits which takes more time.
What is MVC?
It’s an architectural design pattern that separates an application into three main logical components; Model, View, Controller.
What are access modifiers/ specifiers?
They’re accessibility levels, all types and members have accessibility levels, they control whether they can be used from other code in the assembly or other assemblies.
What are all the types of access modifiers?
Public Private Internal Protected Protected Internal
What is a public and private access modifier?
Private members are available only within the containing type whereas public members are available anywhere. There’s no restriction for public members.
What is a protected access modifier?
Protecting members are available within the containing type and to the types that are derived from the containing type.
What is an internal access modifier?
Internal access modifiers are available anywhere within the containing assembly.
What is a protected internal access modifiers?
Can be accessed anywhere within the assembly in which it is declared or form within a derived class in another assembly. It is a combination of protected and internal.
What are namespaces and why do we use them?
They’re used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.
What are constructors?
Constructors are special types of methods of a class that automatically get executed whenever we create an instance (object) of that class. The constructors are responsible for two things. Object initialization and memory allocation.
Note: The constructor name must match the class name and it cannot have a return type. The constructor is called when the object is created. All classes have constructors by default, if you do not create a class constructor yourself, c# creates one for you. However, then you are not able to set initial values for those fields.
What is dependency injection?
Its a design pattern where an object receives other objects that it depends on.
Why do we use dependency injection?
Makes our code more maintainable.
What is a class?
Can be described as the blueprint of a specific object. The class is a blueprint from which the individual objects are created.
What is an object?
An object is an instance of a class. Can be considered as a thing that can perform activities. The set of activities that the object performs defines the object’s behavior.
What is an abstract class?
A special type of class that can be instantiated. It’s designed to be inherited by subclasses. The subclass must override its method.
What is a concrete class?
A simple class with members such as methods and properties.
What is a sealed class?
Can not be inherited by any other class.
What is a partial class?
Allow us to define a class on multiple files.
What is a static class?
Basically the same as a non-static class but a static class can’t be instantiated. All the members of the class are static.
What are methods?
A code block that contains a series of statements. A program causes the statements to be executed by calling the method. In C#, every executed instruction is performed in the context of a method.
What does the static keyword mean?
Only one instance of the members exist for a class. Static variables are used for defining constants because their values can be retrieved by invoking a the class without creating an instance of it.
Ex: Console.WriteLine
What is data binding?
Process that establishes a connection between the app UI and the data it displays. If everything is connected properly, the when the data changes is value, the elements that are bound to the data will also reflect changes automatically.
What are virtual methods?
Virtual methods have an implementation and provide the derived classes with the option of overriding it.
What is a heap and stack?
There are two types of memory allocation; stack and heap memory.
Stack is used for static memory allocation and heap for dynamic memory allocation both stored in the computer’s ram.
Object types need dynamic memory while primitive data types need static memory.
Primitive types: int, bool, float, short, double, object reference
Objects and strings are stored on the heap. But their reference pointer is stored on the stack (value is null) and points to the heap.
It will clear all memory on the stack once the method has been executed (in a LIFO approach). Garbage collector cleans up the heap.