Inheritance, together with encapsulation and polymorphism, is one of the three primary characteristics (or pillars) of object-oriented programming. Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those […]
In order to refresh and consolidate main paradigms of OOP let’s talk about encapsulation first: Encapsulation, in object oriented programming methodology, prevents access to implementation details. It enables a group of properties, methods and other members to be considered a single unit or object.
Nullable types are instances of the System.Nullable struct. They are value types, though we can assign null to them. For example int? is a Nullable<Int32>. All nullable types have two values: The value of the data type. A boolean value that tells if value has been set(HasValue property). DateTime also is value type, btw
Fundamental differences between struct and class. Class Class is a reference type and its object is created on the heap memory. Class can inherit the another class. Class can have the all types of constructor and destructor. The member variable of class can be initialized directly. Class object can not be created without using the new […]
I just show you a piece of code, that is self-explanatory: When using explicit interface implementation the functions are not public in the class. So first, we need either assign this object to interface variable or cast it to the interface type.
Virtual method is a method that can be overridden in derived class. It can have implementaion in a base class, though. Let’s see the example. In this example we override method G() of class A, since it is marked with virtual keyword and we use override keyword in class B.
An interface declaration may declare zero or more members. An interface cannot contain constants, fields, operators, instance constructors, destructors, or types, nor can an interface contain static members of any kind. All interface members implicitly have public access. It is a compile-time error for interface member declarations to include any modifiers. In particular, interfaces members […]
People don’t see the difference between events and delegates sometimes. Delegate is a class that contains a field that holds a reference to a method and then you can call the method with appropriate parameters. Whereas an event is a variable that you can define and specify one or more delegates to be added to it.