日期:2014-05-18 浏览次数:20933 次
static void Main(string[] args) { Custom c = new Custom(); c.ch += new Changed(delegate() { Console.WriteLine("Changed"); }); c.Str = "123"; c.Str = "234"; c.Str = "234"; #endregion } delegate void Changed(); class Custom { public event Changed ch; private string str; public string Str { get { return str; } set { if (str != value) { if (ch != null) ch(); } str = value; } } }