Inheritance
Programming in .NET environment allows the user to use a base class
to provide inheritance for the programmer. This provides a generic
set of objects to base class and modifies it somewhat to add or remove
parts of the base class. This can be thought of as cutting and pasting
code without going through the actions.
All objects in the .NET framework are derived from the System.Objects base class. If you do not provide the name of a different base class, this is the implied class. Using the VisualStudio .NET Object Browser allows the user to include different inheritance.
In .NET, our objects inherit the functionality free from the base class. What makes inheritance so special in .NET is that a class written in one language can be cross-referenced in another language. The CLR allows the .NET applications to utilize this feature in writing classes in different languages and sharing the base class. The object constructors have been modified in order to use this inheritance feature. The Visual Basic Class_Initialize event has been modified to act as a C++ event. An example of how .NET object classes provide inheritance with an object constructor is below.
Public Class ConstructorDemoComponent
Dim m_x, m_y As
Integer
Public Overloads
Sub New ()
MyBase.New
( )
m_x = 0
m_y = 0
End Sub
Public Overloads Sub New (x as Integer, y as Integer)
MyBase.New ( )
m_x = x
m_y = y
End Sub
End Class
Memory Management
Most object-oriented programming in the past had problems with crashing due to lack of memory space. With NET, this problem is averted. The .NET CLR automatically manages the memory available to any application. The CLR allocates the object’s memory from the managed heap. You cannot forget to delete an object because the system has a function to clear it for you.
Garbage collection takes place when the garbage collector feels like it, but the user can specify when to collect the garbage with the System.GC.Collect function. This should be implemented at logical points in the program to clear away debris before starting a large operation.