Overloading vs Overriding in c#

Overloading
Overloading is when you have multiple methods in the same scope, with the same name but different signatures.
//Overloading
public class test
{
    public void getStuff(int id)
    {}
    public void getStuff(string name)
    {}
}
Overriding
Overriding is a principle that allows you to change the functionality of a method in a child class.
//Overriding
public class test
{
        public virtual getStuff(int id)
        {
            //Get stuff default location
        }
}

public class test2 : test
{
        public override getStuff(int id)
        {
            //base.getStuff(id);
            //or - Get stuff new location
        }
}

Comments

Popular posts from this blog

Convert List Collection to DataTable using C#

Difference Between Site Template and Site Definition

SharePoint 2010 Content Query Web Part