Advertisement
DigitalMag

Event trigger inside another class instaed initialized place

Mar 20th, 2020
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.  
  13.     public partial class Receiver
  14.     {
  15.         public partial class Form1 : Form
  16.         {
  17.             Receiver receiver = new Receiver();
  18.  
  19.             public Form1()
  20.             {
  21.                 InitializeComponent();
  22.  
  23.             }
  24.  
  25.             private void button1_Click(object sender, EventArgs e)
  26.             {
  27.                 // наше событие, которое будет триггерить
  28.                 receiver.Received(new List<string> { "the string" });
  29.             }
  30.         }
  31.     }
  32.  
  33.  
  34.     public delegate void OnReceived(List<string> args);
  35.  
  36.     interface IReceived
  37.     {
  38.         event OnReceived Received;
  39.     }
  40.  
  41.     // [ImmutableObject(false)]
  42.     // [Inheritance]    
  43.     public partial class Receiver : IReceived
  44.     {
  45.         public event OnReceived Received;
  46.  
  47.  
  48.     }
  49.  
  50.     public class Target
  51.     {
  52.  
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement