What Is Polymorphism
What Is Polymorphism
Example 1
The compiler checks the type and number of parameters passed to the
method and decides which method to call at the compile-time and it will
give an error if there are no methods that matches the method signature
of the method that is called at the compile-time.
namespace MethodOverloadingByManishAgrahari
{
class Program
{
public class TestOverloading
{
public void Add(string a1, string a2)
{
Console.WriteLine("Adding Two String :" + a1 + a2);
}
public void Add(int a1, int a2)
{
Console.WriteLine("Adding Two Integer :" + a1 + a2);
}
}
static void Main(string[] args)
{
TestOverloading obj = new TestOverloading();
obj.Add("Manish " , "Agrahari");
obj.Add(5, 10);
Console.ReadLine();
}
}
Virtual Modifier
Inheritance in VB.NET
Inheritance is the idea that one class, called a subclass, can be based on
another class, called a base class. Inheritance provides a mechanism for
creating hierarchies of objects. For example, a dog is a mammal and a
collie is a dog. Thus the dog class inherits the properties and methods of
the mammal class, and the collie class inherits from
both dog and mammal.
Support for implementation inheritance is perhaps the biggest change in
Visual Basic.NET. Table shows the new keywords that have been added
along with new statements and methods.
Get
ClassName = "Person"
End Get
End Property
Get
BaseClassName = "Person"
End Get
End Property
Get
FirstName = c_sFirstName
End Get
c_sFirstName = Value
End Set
End Property
Get
LastName = c_sLastName
End Get
c_sLastName = Value
End Set
End Property
End Sub
End Class