top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Output of a program with base class and derived class in c#?

+1 vote
352 views
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();    
    }
  }    
}
posted Nov 26, 2014 by Manikandan J

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

1 Answer

+2 votes
 
Best answer

I am in Static C
I am in A
I am in B
I am in C

answer Nov 26, 2014 by Salil Agrawal
Similar Questions
+3 votes

By-default all the methods & variables in class are private.

In C#.net Main() method is private then how compiler access this Main() Method out side the class because compiler is not part of our program then how compiler access this Main() method?

Here we loose our data abstraction property ? Can anyone put some light on it?

+4 votes

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

+3 votes

What does ? (question mark) after a type name mean in C#?

...