Одна иллюстрация

namespace ConsoleApp14
{
class Shape { public void Method1() { Console.WriteLine(“Method1″); } }
class Circle : Shape { public void Method2() { Console.WriteLine(“Method2″); } }

public interface IContainer
{
T Figure {get;}
}
public class Container : IContainer
{
private T figure;
public T Figure
{
get { return figure; }
}
public Container(T figure)
{
this.figure = figure;
}

}
class Program
{
static void Main(string[] args)
{
Circle circle = new Circle();
IContainer container = new Container(circle);

Console.WriteLine(container.Figure.ToString());
container.Figure.Method1();

Console.ReadKey();
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>