CSharp examples for Custom Type:abstract
Create an abstract base class with nothing but an Output() method.
using System;/* w ww . j a v a 2s . co m*/ abstract public class AbstractBaseClass { abstract public void Output(string outputString); } public class SubClass1 : AbstractBaseClass { override public void Output(string source) // Or "public override". { string s = source.ToUpper(); Console.WriteLine("Call to SubClass1.Output() from within {0}", s); } } public class SubClass2 : AbstractBaseClass { public override void Output(string source) // Or "override public". { string s = source.ToLower(); Console.WriteLine("Call to SubClass2.Output() from within {0}", s); } } class Program { public static void Test(AbstractBaseClass ba) { ba.Output("Test"); } public static void Main(string[] strings) { SubClass1 sc1 = new SubClass1(); Test(sc1); SubClass2 sc2 = new SubClass2(); Test(sc2); } }