it's batter option is Overloading,
Polymorphism:
When a message can be processed in different ways is called polymorphism. Polymorphism means many forms.
Polymorphism is one of the fundamental concepts of OOP.
Polymorphism provides following features:
It allows you to invoke methods of derived class through base class reference during runtime.
It has the ability for classes to provide different implementations of methods that are called through the same name.
Polymorphism is of two types:
Compile time polymorphism/Overloading
Runtime polymorphism/Overriding
Compile Time Polymorphism
Compile time polymorphism is method and operators overloading. It is also called early binding.
In method overloading method performs the different task at the different input parameters.
Runtime Time Polymorphism
Runtime time polymorphism is done using inheritance and virtual functions. Method overriding is called runtime polymorphism. It is also called late binding.
When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same prototype.
Caution: Don't confused method overloading with method overriding, they are different, unrelated concepts. But they sound similar.
Method overloading has nothing to do with inheritance or virtual methods.
1. More info click here,
2. More info click here
using System;
class Test
{
static void Foo(int x, int y)
{
Console.WriteLine("Foo(int x, int y)");
}
static void Foo(int x, double y)
{
Console.WriteLine("Foo(int x, double y)");
}
static void Foo(double x, int y)
{
Console.WriteLine("Foo(double x, int y)");
}
static void Main()
{
Foo(5, 10);
}
}