Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- var conn = new Conn();
- var work = new Work(conn);
- conn.Raise();
- }
- }
- public class Conn
- {
- public Conn()
- {
- UserEvent += eventWorker;
- }
- private void eventWorker()
- {
- Console.WriteLine("1");
- }
- private int age;
- private string name;
- public delegate void UI ();
- public event UI UserEvent;
- public void Raise()
- {
- if (UserEvent != null)
- UserEvent();
- }
- }
- public class Work
- {
- private Conn _conn;
- public Work(Conn conn)
- {
- _conn = conn;
- MajorWork();
- }
- private void MajorWork()
- {
- _conn.UserEvent += eventWorker;
- }
- private void eventWorker()
- {
- Console.WriteLine("2");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement