Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. public class SomeClass
  2. {
  3. public T Coerce<T>() where T : class
  4. {
  5. if (typeof(T) == typeof(SomeClass))
  6. return this as T;
  7. else throw new InvalidCastException();
  8. }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement