What is the difference between a non-stationary method and a static method of an abstract class?

I know that using the Static method in an abstract class is not recommended, but what's the difference. If I use both static and non-stationary method in an abstract class.

I assume that there is no difference in calling these methods, because we cannot create an instance for an abstract class, so we can call both static and non-static methods using only the class name.

Is there any other difference between them besides the keyword "Static"?

Example: Abstract class:

abstract public class AbstractClass
{
    #region Constructor
    protected AbstractClass(Args args): this(args)
    {
    }
    #endregion

    #region public static methods

    public static object FormLoad(Args args)
    {
        //Logic 
    }

    public static object Sample(Args args)
    {
        //Logic
    }

    #endregion


    #region Public non-static methods

    public AbstractClass CreateResponse(Args args)
    {
        //Logic
    }

    public void ClearDialog()
    {
        //Logic
    }

    #endregion

    #region Abstract Method
    abstract protected void Responses();
    #endregion

}

Derived class:

   public class DerivedClass : AbstractClass
   {
    #region Public Constructors

    public DerivedClass(Args args)
        : base(args)
    {
    }

    #endregion

    #region Protected Methods

    protected override void Responses()
    {
        //logic
    }

    #endregion
    }
+4
source share
2 answers

. :

Logger.Configure();

Logger Configure . . , Logger.NonStaticMethod() .

. , :

public class DerivedClass: AbstractClass
{
    public DerivedClass(Args args)
        : base(args)
    {
    }

    protected override void BuildResponses()
    {
        FormLoad(args);
    }
}

, factory:

public abstract class Logger
{
    public static Logger NLog()
    {
        return new NLogLogger();
    }
}

...

var logger = Logger.NLog();
logger.Log("Message");

BCL: WebRequest.Create(...), , HttpWebRequest, FtpWebRequest , WebRequest.

+1

-

, , ,

, , , , Static . abstract, , , , Shape. - , , Circle square. , , , , .

? , .

, , , , , , , , .

MyAbstractClass.StaticMethod();
+1

All Articles