Class libraries – shared assemblies

This post is a continuation of Class libraries - private assemblies A class library is a *.dll (dynamic link library) file containing types that can be used by external applications. Assemblies can be private or shared. The main difference is that the same copy of the shared assembly can be used by many applications, whereas with the private … Continue reading Class libraries – shared assemblies

Class libraries – private assemblies

If you have some code that you want to use multiple times in different applications, extract it to a custom class library! Even when you think you are not using any external library, each of your applications uses many types from mscorlib.dll - a .NET library that is always accessible,  as C# compiler uses it automatically - or … Continue reading Class libraries – private assemblies

Static constructor

You can create static methods, static fields, classes and even static constructors. Static constructors? Oh, yes. 🙂 Static constructor can be included both in a static class or a non-static class. A constructor in a static class? But a static class cannot be instantiated! No problem. In a static class the constructor gets invoked when … Continue reading Static constructor

Singleton versus static fields

A singleton is a class which only allows a single instance of itself to be created. But why do I need a whole design pattern for this? Why not simply use static fields? Static field object gets created before the application starts If you assign an object to a static field it gets created before the … Continue reading Singleton versus static fields

Use of base and this keywords with constructors

Base keyword The base keyword is used to access members of the base class from within a derived class. You can use it in two ways: To call a method on the base class that has been overridden by another method To specify which base class constructor should be called INSTEAD of the default PARAMETERLESS … Continue reading Use of base and this keywords with constructors