-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
51 lines (41 loc) · 1.09 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sample2
{
class Program
{
static void Main(string[] args)
{
Order Order = new Order();
Order.Key = 12;
Order.Changed += Order_Changed;
Order.Save();
}
private static void Order_Changed(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
public delegate void ChangedEventHandler(object sender, EventArgs e);
public class Order
{
public int Key { get; set; }
public event ChangedEventHandler Changed;
// Invoke the Changed event; called whenever list changes
protected virtual void OnChanged(EventArgs e)
{
if (Changed != null)
Changed(this, e);
}
public Order Save()
{
Order Order = new Order();
Order.Key = 12;
OnChanged(EventArgs.Empty);
return Order;
}
}
}