Hello Friends,
After Click on project Select Console Application than provide your Application name and Browse Your Location Where You will save this application than click on OK. Like this snapshot.Please follow this step.
In Previous Chapter I had
described about method
overriding which was the concept
of Run time polymorphism in C# dotnet.
But Now I am going to describe how to Overload
a Method which is the Concept of Compile
time Polymerphism .It means that same
method will be implement in different
argument and how can access it.
Please follow this steps.
Step-1:
Open Visual
Studio Go to file menu select option “New” than Choose option
“Project...” like this snapshot.
After Click on project Select Console Application than provide your Application name and Browse Your Location Where You will save this application than click on OK. Like this snapshot.Please follow this step.
Step-2:
Code of Method Overriding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace overloadmethod
{
class Program
{
public
void
myapp(int p,int q)
{
Console.WriteLine(p*q);
}
public void myapp(string s)
{
Console.WriteLine(s.Length);
}
public
void
myapp(int p,int q,int r)
{
Console.WriteLine(p+q+r);
}
public
static
void
Main(string[] args)
{
Program
obj = new Program();
obj.myapp(20,10);
obj.myapp("97865");
obj.myapp(10,30,10);
}
}
}
Step-3:
After
write this code please press to Ctrl+F5 than Output will Come like this.
Thanks
Rabinarayan
No comments:
Post a Comment