Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 6
In c# event is a callback function. When a work is done, a value got changed, a part of a work is done and in other cases you could use an event to get the feedback. Event is higher version of Action. Action and event both must be invoked. Use it when you are making a file management software and in windows form application.
Syntax :
void event_name(object sender, EventArgs e) { }
Example :
void set_event(MyFile file)
{
file.OnDownloadComplete += complete;
}
void complete (object sender, EventArgs e)
{
//Download complete.
}
class MyFile {
event OnDownloadComplete;
//constructors, functions and other things...
}