DefconDotNet

Untitled

Dec 11th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1.  
  2.     public class Animal
  3.     {
  4.         public T Promote<T>() where T : Animal
  5.         {
  6.             return this as T;
  7.         }
  8.     }
  9.     public class Dog : Animal
  10.     {
  11.        
  12.     }
  13.     public class test
  14.     {
  15.         public void ttt()
  16.         {
  17.             Animal animal = new Animal();
  18.             Dog dog = animal.Promote<Dog>();
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment