Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. class Program
  2. {
  3. public static Func<Object, bool> delegateFunc { get; set; }
  4.  
  5. static void Main()
  6. {
  7. // check if type is a class
  8. delegateFunc = IsAClass;
  9. Console.WriteLine(delegateFunc(new List<int>()));
  10.  
  11. // check if type is a delegate
  12. delegateFunc = IsADelegate;
  13. Console.WriteLine(delegateFunc(delegateFunc));
  14. }
  15.  
  16. static bool IsAClass(Object obj)
  17. {
  18. return obj.GetType().IsClass;
  19. }
  20. static bool IsADelegate(Object obj)
  21. {
  22. return obj is Delegate;
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement