Base class and interface : Interface : Class C# Examples


C# Examples » Class » Interface »

 

Base class and interface









    
public  class  Component
{
        public  Component()  {}
}

interface  Printable
{
        void  printHeader(float  factor);
        void  printFooter(float  factor);
}

public  class  TextField:  Component,  Printable
{
        public  TextField(string  text)
        {
                this.text  =  text;
        }
        //  implementing  Printable.printHeader()
        public  void  printHeader(float  factor)
        {
                
        }
        
        //  implementing  Printable.printFooter()
        public  void  printFooter(float  factor)
        {
                
        }
        
        private  string  text;
}

class  MainClass
{
        public  static  void  Main()
        {
                TextField  text  =  new  TextField("Hello");
                
                Printable  scalable  =  (Printable)  text;
                scalable.printHeader(0.5F);
                scalable.printFooter(0.5F);
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Interface