Cash
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Person NewPerson = new Person(); NewPerson.AddCash(150); NewPerson.Myevent += NewPerson_Myevent; } static void NewPerson_Myevent() { Console.WriteLine("Hello New Person"); } } public class Person { public delegate void MyeventHandler(); public event MyeventHandler Myevent; private int _cash = 50; public int Cash { get { return this._cash; } set { this._cash = value; if (this._cash >= 100) { if (Myevent != null) { Myevent(); } } } } public void AddCash(int money) { Cash += money; } } }
Person NewPerson = new Person(); NewPerson.Myevent += NewPerson_Myevent; NewPerson.AddCash(150);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)