Hello Friends,
Now I
am going to describe how to override the
method in C#.net.This is purely console application of Dynamic or runtime polymorphism in C# Application.So Please follow the following 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 overridingconcept
{
class Program
{
public virtual void overrideprog(int p, int q)
{
Console.WriteLine(p + q);
}
public static void Main(string[] args)
{
prog obj = new prog();
obj.overrideprog(50, 60);
}
class prog : Program
{
public override void overrideprog(int p, int q)
{
Console.WriteLine(p * q);
}
}
}
}
Step-3:
Thanks
No comments:
Post a Comment