Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Person
- {
- public event Action PersonEat;
- public Action PersonEatAction;
- public Person()
- {
- }
- protected void OnPersonEat()
- {
- PersonEat.Invoke();
- PersonEat = null;
- }
- }
- class Program
- {
- private static void NotifyMe()
- {
- ///
- }
- static void Main(string[] args)
- {
- var person = new Person();
- // Only allowed inside type Person.
- //person.PersonEat(); // not allowed
- //person.PersonEat = NotifyMe; // fails
- person.PersonEat += NotifyMe;
- person.PersonEatAction();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement