Mega Code Archive

 
Categories / C# Tutorial / Class
 

Inheritance from both class and interface

using System; public class Control {     public void Serialize() {         Console.WriteLine("Control.Serialize called");     } } public interface IDataBound {     void Serialize(); } public class EditBox : Control, IDataBound { } class InterfaceInh2App {     public static void Main() {         EditBox edit = new EditBox();         IDataBound bound = edit as IDataBound;         if (bound != null) {             Console.WriteLine("IDataBound is supported...");             bound.Serialize();         } else {             Console.WriteLine("IDataBound is NOT supported...");         }     } }