using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace events { delegate void onChange(object handle, EventArgs args); class Teplomer { public event onChange zmena; double teplota; public double Teplota { get { return teplota; } set { if (value != teplota) { teplota = value; if (zmena != null) zmena(null, null); } } } } static class Program { static void Main() { Teplomer t = new Teplomer(); t.zmena += delegate(object handle, EventArgs args) { Console.WriteLine("Zmeniala se teplota."); }; Console.WriteLine("merim"); t.Teplota = 5; Console.WriteLine("merim"); t.Teplota = 10; Console.WriteLine("merim"); t.Teplota = 10; Console.ReadLine(); } } }