ref return returns the storage location and ref locals can store that in a local variable. But ref readonly locals(C# 7.2) doesn't allow writes to that object instead of read value.
- sealed class can't be inherited
- sealed method can't be override in a derived class
Example of sealed class,
Example of sealed method,
EF Core development approaches
Entity Framework (EF) Core 2.0 doesn't support visual designer or wizard for DB model (edmx). EF Core supports only two development approaches,
- Code-First
- Database-First.
Compile time vs. run time polymorphism
Polymorphism (means one name, multiple forms) one interface and many implementations.
Binding/type of polymorphism
Binding is the connection of a method call to a method implementation.
Compile-time polymorphism (early-binding/overloading/static binding)
Method overloading
The same name of the methods in the same class take multiple implementation forms.
Operator overloading
Run-time polymorphism (late-binding/overriding/dynamic-binding)
It is implemented using inheritance and virtual method.
Abstract method vs. virtual method
- Virtual method has default implementation as well as provides the derived class with an option of overriding it.
- Abstract method doesn’t provide default implementation and forces the derived class to override the method.
Abstract class vs. interface
- Accessibility modifier (public/internal etc.) is allowed for abstract class. Interface doesn't allow accessibility modifier.
- Class can inherit only one abstract class; class can implement more than one interface.
- Abstract classes can have default implementations for some of its (virtual) members (methods), but the interface class holds only the signature. It can't have implementation for any of its members. But C# 8(not release yet) supports default implantation of the methods in the interface.
Example,
Application domain
Application Domain provides a logical isolated boundary of the application for security. All the objects of the same application are created within the same application domain. Application Domain keeps assemblies separate within a single process.
Serialization vs. deserialization
- Serialization: Transforming object to XML string.
- Deserialization: Transforming XML string to object.
More details click here,
Use of stream
When data size is too large then it is very difficult to load whole data into the memory at the same time. Stream is used to read data from large file. You can read small chunks of data where the large file is broken down into small chunks.
Http post vs. put
- Post is used to create new entity
- Put is used to update an existing entity.
Process vs. thread
Threads run in a shared memory space, while process run in separate memory spaces.
When you double-click on the Outlook icon, you start the application in OS which is a process. The process is an executing instance of an application.
You can consider “auto spelling & grammar check” and “auto check names” as threads in Outlook. A thread is a path of execution within a process.
The mechanisms to run code in parallel
Example of the simple signatures,
Synchronization mechanisms in threads
When multiple threads share resources (share data) then it might produce problems. The producer-consumer and the reader-writer problems are the most common example. To avoid the problem, we need to synchronize to access the data.
The source code is added on the top of this article. Find the attachment.