Category Archives: C#

What is an Event in C#

By | September 10, 2017

An event is a member that enables a class or object to provide notifications. An event is declared like a field except that the declaration includes an event keyword and the type must be a delegate type. Within a class that declares an event member, the event behaves just like a field of a delegate… Read More »

Category: C#

When to use Static Constructor?

By | September 10, 2017

A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed once only. It is called automatically before the first instance is created or any static members are referenced. class SimpleClass { // Static variable that must be initialized at run time.  static readonly long baseline; //… Read More »

Difference between constants and read-only variables.

By | August 25, 2017

While constants and read-only variable share many similarities, there are some important differences: Constants are evaluated at the compile-time, while the read-only variables are evaluated at the runtime. Constants support only value-type variables, while read-only variables can hold reference type variables also. Constants should be used when the value is not changing during the runtime,… Read More »

Category: C#