Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Anonymous
{
// Object Orianted Programmeng
// Anonymous
// 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)
{
Absence myAbsence = new Absence(10);
/* test one
// event activ
myAbsence.AbsenceEvent += new myDelegate(myAbsence.AlertEvent);
*/
// test tow
// Anonymous
myAbsence.AbsenceEvent += delegate()
{
Console.WriteLine("Warning !");
};
// END
myAbsence.Verify_Absence(8);
Console.Read();
}
}
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more