Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace JustMyTests
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var p = new MyPresenter();
  10.             Presenter ip = p; // error!
  11.         }
  12.     }
  13.  
  14.     interface IModel
  15.     {
  16.     }
  17.  
  18.     interface IPresenter<in T>
  19.         where T : class, IModel
  20.     {
  21.         void SomeMethod(T t);
  22.     }
  23.  
  24.     class Presenter
  25.     {
  26.          
  27.     }
  28.  
  29.     abstract class Presenter<T> : Presenter, IPresenter<T>
  30.         where T : class, IModel
  31.     {
  32.         public abstract void SomeMethod(T t);
  33.     }
  34.  
  35.     class MyModel : IModel
  36.     {        
  37.     }
  38.  
  39.     class MyPresenter : Presenter<MyModel>
  40.     {
  41.         public override void SomeMethod(MyModel t)
  42.         {
  43.             Console.WriteLine("Hello!");  
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement