Search code examples
c#overridingparentabstract

Can i override an abstract method written in a parent class, with a different name in a child class?


abstract class SettingSaver
    {


        public abstract void add(string Name, string Value);
        public abstract void remove(string SettingName);


    }


class XMLSettings : SettingSaver
    {

        public override void add(string Name, string Value)
        {
            throw new NotImplementedException();
        }

        public override void remove(string SettingName)
        {
            throw new NotImplementedException();
        }




    }

Is there anyway that I can change the name of the add function in XMLSettings class to addSetting but make sure it overrides the add function in the SettingSaver? I know it should be definitely overridden in derived classes but just want to know whether I can use a different name :) Thanx in advance :D


Solution

  • No, you can't change the name when you override a method in C#.

    Of course, you can override the method and implement it just by calling a different method.

    (On a naming convention note, methods are typically PascalCased, starting with a capital letter. Parameters are typically camelCased, starting with a lower case letter.)