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;
- namespace EventsPractice
- {
- public delegate void myEventHandler(string newValue);
- public class EventExample
- {
- private string _value;
- public event myEventHandler valueChanged;
- public string val
- {
- set
- {
- _value = value;
- valueChanged(_value);
- }
- }
- static void myEvt_valueChanged(string newValue)
- {
- Console.WriteLine("The value changed to {0}", newValue);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EventsPractice;
- namespace EventsPractice
- {
- public class Program
- {
- static void Main(string[] args)
- {
- EventExample myEvt = new EventExample();
- myEvt.valueChanged += myEventHandler(myEvt_valueChanged);
- string str;
- do
- {
- str = Console.ReadLine();
- if (!str.Equals("exit"))
- myEvt.val = str;
- } while (!str.Equals("exit"));
- }
- }
- }
Add Comment
Please, Sign In to add comment