Загрузка...

Part -14 Method hiding in C#

Method hiding in C#
1.Method hiding
2.Invoke hidden methods.


Method hiding:

it is a hiding methods of base class from derived class, you can hide the implementation of the methods of the base class from derived class by using new keyword.



internal class Program
{
public static void Main()
{

Employee EMP = new FullTimeEmployee();
EMP.Displaymessage();

}
}

public class Employee
{
public int EmpID { get; set; }
public string EmpName { get; set; }

public void Displaymessage()
{
Console.WriteLine("this is employee method");
}
}
public class FullTimeEmployee:Employee
{
public new void Displaymessage()
{
Console.WriteLine("this is FullTimeemployee method");
}
}
public class PartTimeEmployee : Employee
{
public new void Displaymessage()
{
base.Displaymessage();
}
}

Видео Part -14 Method hiding in C# канала Code Insights by Surya
Яндекс.Метрика

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять