top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Is overriding of a function is possible in the same class?

0 votes
450 views
Is overriding of a function is possible in the same class?
posted May 15, 2017 by Pooja Bhanout

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

No you cannot override a method in the same class as over riding is a concept of inheritance where you want to expose the child class functionalities rather then base class. Hence it has to be in child class.

answer May 17, 2017 by Shweta Singh
Similar Questions
+1 vote
using System;

namespace CareerRideTest
{    
  class A
  {    
    public A()
    {
      Console.WriteLine("I am in A");
    }
  }

  class B : A
  {
    public B()
    {
      Console.WriteLine("I am in B");
    }
  }

  class C : B
  {
    static C()
    {
      Console.WriteLine("I am in Static C");
    }
    public C()
    {
      Console.WriteLine("I am in C");
    }
  }    

  class MainClass
  {
    static void Main(string[] args)
    {
      C obj = new C();    
      Console.ReadKey();    
    }
  }    
}
+4 votes

Why can’t we use a static class instead of singleton?

...