public
class
Class1
{
public
void
NumbersAdd(
int
a,
int
b)
{
Console
.WriteLine(a + b);
}
public
void
NumbersAdd(
int
a,
int
b,
int
c)
{
Console
.WriteLine(a + b + c);
}
}
//Base Class
public
class
Bclass
{
public
virtual
void
Sample1()
{
Console
.WriteLine(
"Base
Class"
);
}
}
// Derived Class
public
class
DClass
:
Bclass
{
public
override
void
Sample1()
{
Console
.WriteLine(
"Derived
Class"
);
}
}
// Using base and derived class
class
Program
{
static
void
Main(
string
[] args)
{
// calling the overriden method
DClass
objDc =
new
DClass
();
objDc.Sample1();
// calling the base class method
Bclass
objBc =
new
DClass
();
objBc.Sample1();
}
}
Output
Derived Class
Derived Class
Hi Guys,
ReplyDeleteIf you have any questions regarding the blog please write to me.