Unity container is a lightweight dependency injection container. It manages creation and resolution of objects that we registered based on life time that we specified. Here is a list of lifetime managers that exist in Unity.
I often bumped into questions like: What is the GetHashCode metho? Why use it? How to implement it correctly? So let’s try to ask on them. What is GetHashCode used for? It is used for putting object in a hash table. Why do we have this method implemented on Object? In order to be able […]
Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements. Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original […]
Why it is bad practice to use virtual method inside the constructor? When you make a virtual method call in a constructor, and it is not the most derived type in its inheritance hierarchy, that it will be called on a class whose constructor has not been run, and therefore may not be in a […]
Contra-variant Meaning that the generic type parameter can change from a class to a class derived from it. In C#, you indicate contra-variant generic type parameters with the in keyword. Contra-variant generic type parameters can appear only in input positions such as a method’s argument. Covariant Meaning that the generic type argument can change from a class to […]
When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile-time error. These restrictions […]
Often in our application development we need to acquire and release some resources. That unmanaged resources could be files that we want to use from time to time, database connections, fonts etc. The important thing is to release resources once we have done with it. Since the CLR uses Garbage Collection to manage lifecycle of objects […]
The difference between abstract class and interface can be described in following table: Interface Abstract class Interface support multiple inheritance Abstract class does not support multiple inheritance Interface doesn’t Contains Data Member Abstract class contains Data Member Interface doesn’t contains Constructors Abstract class contains Constructors An interface Contains only incomplete member (Events, properties, methods, indexers) […]