Run Code
|
API
|
Code Wall
|
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
string test
haha
Convert String to integer in c#
dfdfdff
testing_editor
fun with yield return
Dungeon Game
test2
Generic hierarchy
Out reference example