CSharp examples for Custom Type:interface
using an interface to hide parts of a class that you don't want certain users to call.
using System;/*from ww w . jav a2s. c o m*/ class Program { public class Rectangle : Shape { public void GetArea() // Safe. { Console.WriteLine("Rectangle: Climbing stairs."); } public void Draw() // Safe? Might break it. { Console.WriteLine("Rectangle: Petting the nice doggie."); } public void Charge() { } public void Move() { } public void Paint() { } public static Shape CreateRectangle() { return (Shape)new Rectangle(); } } public interface Shape { void GetArea(); void Draw(); } static void Main(string[] args) { Shape myZilla = Rectangle.CreateRectangle(); myZilla.GetArea(); myZilla.Draw(); } }