How to call a base class constructor from a derived class?

How to call a base class constructor from a derived class?

using System;
using System.Collections.Generic;
using System.Text;

namespace OOPTest7
{
class A
{
public A()
{
Console.Out.Write("base A");
}
public A(string s)
{
Console.Out.Write(s);
}

}

class B : A
{

public B() : base("base cons called from Derived")
{
Console.Out.Write("B");
}

}



class Program
{
static void Main(string[] args)
{
B b= new B();
Console.In.Read();
}
}
}

0 comments:

Post a Comment