Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SomeClass
- {
- public T Coerce<T>() where T : class
- {
- if (typeof(T) == typeof(SomeClass))
- return this as T;
- else throw new InvalidCastException();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement