If methods are declared in a child and base class with the same signature but without the keywords virtual and override, the child class function is said to hide the base class function. The method in the child class is denoted with the New keyword.
For e.g.
public class VirtualDemo
{
public void Hello ()
{
Console.WriteLine("Hello in Base Class");
}
}
public class A : VirtualDemo
{
public new void Hello ()
{
Console.WriteLine("Hello in Derived Class");
}
}
For e.g.
public class VirtualDemo
{
public void Hello ()
{
Console.WriteLine("Hello in Base Class");
}
}
public class A : VirtualDemo
{
public new void Hello ()
{
Console.WriteLine("Hello in Derived Class");
}
}
No comments:
Post a Comment