Monday 29 June 2015

Can we call static method from abstract class in c#?

Yes. We can call static method from abstract class. Static method does not required instance of class. Object of abstract class can’t be created but to call static object  is not required. So we can call static method with abstract class name i.e abstractclass.methodname();

Example :-

public abstract class Abstractest
    {
        public static string Test()
        {
           return  "Static method in abstract class";
        }
    }
static void Main(string[] args)
        {
            Abstractest.Test();
            Console.ReadLine();
        }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.