Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C# Events and Delegates example
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Video vid = new Video("Exciting new content!"); VideoUploader uploader = new VideoUploader(); Subscriber sub = new Subscriber(); Bells bell = new Bells(); uploader.Uploaded += sub.NotifySubscribers; uploader.Uploaded += bell.NotifyBells; uploader.Upload(vid); } } class VideoUploader { public delegate void UploadedHandler(); public event UploadedHandler Uploaded; public void Upload(Video vid) { Console.WriteLine("Uploading new video..."); OnUploaded(); } public void OnUploaded() { Console.WriteLine("Finished uploading."); Uploaded(); } } class Video { public string videoName; public Video (string videoName) { this.videoName = videoName; } } class Subscriber { public void NotifySubscribers() { Console.WriteLine("A new video has been uploaded!"); } } class Bells { public void NotifyBells() { Console.WriteLine("Notified!"); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
1
lookup test
nguoi
Šovljanski - beskonačna petlja bez goto-a
Get Distinct value using Group By , Having , Count in DataTable C#
Decimal Test2
2.2 gz
Celsius to Kelvin / Kelvin to Celsius
split string
Umbraco
Please log in to post a comment.