using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Events_Lambda { // Object Orianted Programmeng // Lambda // delegate public delegate void myDelegate(); // class class Absence // الغياب { // Event public event myDelegate AbsenceEvent; public int Absented_Hours; // Propertys public int Absented_Hours_Property { get { return Absented_Hours; } set { Absented_Hours = value; } } public Absence(int Hours) { this.Absented_Hours = Hours; } public void Verify_Absence(int Max_hours) { if (Absented_Hours > Max_hours) { AbsenceEvent(); } } /* test one public void AlertEvent() { Console.WriteLine("Warning !"); }*/ } class Program { static void Main(string[] args) { // Lambda // example one Absence myAbsence = new Absence(10); myAbsence.AbsenceEvent += () => Console.WriteLine("Warning !"); myAbsence.Verify_Absence(8); // Lambda // example tow List<string> Colors = new List<string> { "Red", "Blue", "Orange", "black" }; Colors.ForEach(Item => { Console.Write("\n\tColors are: - " + Item); }); } } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more