fork download
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. public class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. var tw = new TopWork();
  10. tw.Work();
  11. }
  12. }
  13.  
  14. public class TopWork
  15. {
  16. public Work _work;
  17.  
  18. public TopWork()
  19. {
  20. _work = new Work();
  21. _work._event += new Work.CompleteHandler(Done1);
  22. _work._delegate += new Work.CompleteHandler(Done1);
  23. }
  24.  
  25. public void Work()
  26. {
  27. _work.JustWork();
  28. }
  29.  
  30. private void Done1(int number)
  31. {
  32. Console.WriteLine($"Done1 {number}");
  33. }
  34. }
  35.  
  36.  
  37. public class Work
  38. {
  39. public delegate void CompleteHandler(int number);
  40. public Work.CompleteHandler _delegate;
  41. public event Work.CompleteHandler _event;
  42.  
  43. public void JustWork()
  44. {
  45. _delegate(4);
  46. _event(4);
  47. }
  48. }
  49. }
  50.  
Success #stdin #stdout 0.02s 15892KB
stdin
Standard input is empty
stdout
Done1 4
Done1 4