Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Animal
- {
- public T Promote<T>() where T : Animal
- {
- return this as T;
- }
- }
- public class Dog : Animal
- {
- }
- public class test
- {
- public void ttt()
- {
- Animal animal = new Animal();
- Dog dog = animal.Promote<Dog>();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment