Practical : 10
Subject : .Net
Subject : .Net
Aim : Program in C# to demonstrate function overloading and function overriding.
Source Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace dotnet008
{
class
InternationalZoo
{
public void
pets()
{
Console.WriteLine("Name : lion");
}
public void
pets(string name)
{
Console.WriteLine("Name : {0}", name);
}
public virtual
void pets(string name,string weight)
{
Console.WriteLine("Name : {0} ({1} kg)", name, weight);
}
}
class NationalZoo
: InternationalZoo
{
public
override void pets(string name, string weight)
{
Console.WriteLine("Name : {0} ({1} km/h)", name, weight);
}
}
class pra10
{
static void
Main(string[] args)
{
InternationalZoo iz1 = new InternationalZoo();
iz1.pets();
iz1.pets("dog");
iz1.pets("tiger", "350");
iz1 = new
NationalZoo();
iz1.pets("horse", "108");
Console.ReadKey();
}
}
}
Output :
0 comments:
Post a Comment