[C# Howto] How to Build Disposable Objects

You know that it is not a good practice to use destructors to clean up your objects. You are not supposed to disrupt the garbage collection process either. The “System.Object” class has the “Finalize()” method. But in C#, you cannot override this method. You need to use the destructor instead.

So how do we cleanup used objects or resources?

Continue reading

[C#] Interfaces

No doubt that you have heard of “Interface-based Programming”. In OOP, polymorphism is one of the key features but inheritance-based programming has its limits.

Interfaces help you define the prototype of the functionality, implement the concrete logic in appropriate classes, and invoke the right implementation in a polymorphic way.

Continue reading

[C#] System.Object

The “System.Object” class is the ultimate (master) base class of all classes in the .NET Framework, which means:

  • All methods in the “System.Object” class are available in all .NET objects
  • All classes can be casted into the “System.Object” type

When you create a custom class, you do not need to override any methods in the “Object” class. But sometimes the default implementation of the methods by the “Object” class might not be appropriate for your need. Let’s find out what the “Object” class offers to us.                      Continue reading