Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleEventForUser
  8. {
  9.  
  10. class Program
  11. {
  12.  
  13.  
  14. static void Main(string[] args)
  15. {
  16. Stack<int> stackData = new Stack<int>();
  17. FindEvent fe = new FindEvent();
  18. Sum findSum = new Sum();
  19. fe.onData += fe.EventForData(stackData);
  20.  
  21. }
  22. }
  23. class FindEvent
  24. {
  25. public delegate void MethodContainer();
  26.  
  27. public event MethodContainer onData;
  28.  
  29. public void EventForData(Stack<int> num)
  30. {
  31. num.Push(int.Parse(Console.ReadLine()));
  32. if (num.Peek().GetTypeCode() == TypeCode.Int32)
  33. {
  34. onData();
  35. }
  36. }
  37.  
  38. }
  39. class Sum
  40. {
  41. static void FindSum(Stack<int> num)
  42. {
  43. int sum = 0;
  44. for (int i = 0; i < num.Count(); i++)
  45. {
  46. sum += num.Pop();
  47. }
  48. Console.WriteLine("Сумма введенных числе = {0}", sum);
  49.  
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement