Define base class another cs file : Base Class « Class « C# / CSharp Tutorial






//File: base.cs
using System;


namespace BaseClassNS
{
   public class MyBaseClass
   {
      public void PrintMe()
      {
         Console.WriteLine("I am MyBaseClass");
      }
   }
}

//////////////////////////////////////
//MainClass.cs

using System;
using BaseClassNS;

namespace UsesBaseClass
{
   class DerivedClass : MyBaseClass
   {
   }

   class MainClass
   {
      static void Main()
      {
         DerivedClass mdc = new DerivedClass();
         mdc.PrintMe();
      }
   }
}








7.22.Base Class
7.22.1.Add constructors to base class
7.22.2.Add more constructors to base class
7.22.3.Pass a derived class reference to a base class reference.
7.22.4.Call constructor in base class
7.22.5.Define base class another cs file