Multiple Inheritance in C#

There are situations where multiple inheritance is the best (if not the only) choice when designing a certain model for our program or project. C# unfortunately does not support multiple inheritance and so we must look for ways to adapt our design to make possible its implementation. But C# does offer resources and tricks that can be used to simulate multiple inheritance without radically redesigning our class model, with only adding several auxiliary methods and classes and taking one or two precautions while coding them. I propose a design pattern that lets us simulate multiple inheritance in a C# program … Click here to continue…..

C# Interfaces

The term interface has been used to describe the public interface of a class. The public interface contains methods, properties, indexers and other items that can be accessed by other classes. In this article, a second, related definition of interface is considered. An interface is a code structure that is similar to an abstract class that has no concrete members. An interface can contain public members such as properties and methods but these members must have no functionality. Instead, like abstract members, they define items that must be made concrete within all classes that implement the interface. This means that … Click here to continue…..

C# Abstract Classes

What is an Abstract Class? So far in this tutorial we have considered concrete classes. A concrete class is a simple class with members such as methods and properties. The class describes the functionality of the objects that it can be used to instantiate. Often, when working with inheritance hierarchies, the least specialized base class cannot fully represent a real object. For example, classes that represent cubes, spheres and other three-dimensional objects can all be assigned properties and methods that permit the calculation of their volume and surface area. However, if the base class for these types represents generic 3D … Click here to continue…..

Tagged

C# Delegates

What is a Delegate? A delegate is a special kind of object that holds a reference to a method. The delegate can be called as if it were any other method. However, when called, the underlying referenced method is executed. This simple layer of abstraction is useful because unlike a direct call, the method being used does not need to be known when writing the code. The reference is created at run-time and may be changed repeatedly throughout the life of the executing program. NB: If you have previously used C++ function pointers then you will see many similarities between … Click here to continue…..