Hiding methods in C#.Net

InfoPath alternatives for form designing SharePoint

In this post we will discuss about hiding methods in C#.Net.

If a method with the same signature is declared in both base and derived classes but the methods are not declared as virtual and override, respectively, then the derived class version is said to hide the base class version.

Here suppose the base class method is like below:

Class Employee
{
public GetEmployee()
{
//Logic will go here
}
}

Now the derived class will be like below:

Class MyDerivedEmployee : Employee
{
public GetEmployee()
{
//Logic will go here
}
}

Now since both the method has same signeture, then while accessing the method there will be clash because your program won’t know which method to call.

So C#.Net generates a compile time warning and tell us to use the new keyword while hding a method like below:

Class MyDerivedEmployee : Employee
{
public new GetEmployee()
{
//Logic will go here
}
}

Similar SharePoint 2013 Tutorials


About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply