C# Events and Delegates Made Simple | Mosh

Поділитися
Вставка
  • Опубліковано 16 лис 2014
  • 🔥Get the COMPLETE course (75% OFF - LIMITED TIME): bit.ly/2s3qkxn
    Want to learn more from me? Check out these links:
    Courses: codewithmosh.com
    Blog: programmingwithmosh.com
    Facebook: / programmingwithmosh
    Twitter: / moshhamedani
    Are you confused about events and delegates in C#? Watch this tutorial and your confusion will be gone in 30 minutes!
    Check out my other C# video tutorials:
    Debugging in Visual Studio
    • Debugging C# Code in V...
    Generics
    • C# Generics Tutorial: ...

КОМЕНТАРІ • 1 тис.

  • @sanfordhoffman2392
    @sanfordhoffman2392 7 років тому +184

    I've looked at a lot of tutorials for events. This one did the trick for me. Broken down to its simplest form. Thank you very much Mosh.

    • @MrRasZee
      @MrRasZee 5 років тому +2

      mosh is fairly good, i always cross reference when i study

    • @HingalshDealer
      @HingalshDealer Рік тому +1

      same with me

  • @jakeowsley6552
    @jakeowsley6552 3 роки тому +77

    As a seasoned C++ developer, I don't know why events and delegates aren't explained this way: straightforward and uncomplicated. Thank you, Mosh.

    • @arrrryyy
      @arrrryyy 9 місяців тому +1

      He did not explain the basic but right away went to type of events standard code used only in winforms and webforms

    • @eobardthawne6903
      @eobardthawne6903 7 місяців тому

      ​@@arrrryyywhat is at 1:00 ?

    • @emzyempire658
      @emzyempire658 6 місяців тому

      I couldn't agree more

  • @cyclewithjb
    @cyclewithjb 2 роки тому +2

    Love how you basically started from nothing instead of started with the codes already in place.
    Always thankful for your generosity and willingness to teach other people.

  • @Phcodesign
    @Phcodesign 5 років тому +18

    Clear and uncluterred as usual. Mosh is one of my favorite teachers. I respect all my teachers, and so the Mosh! Thanks!

  • @zithfrg
    @zithfrg 8 років тому +21

    One of the best tutorials I have ever seen in UA-cam. You gained a new subscriber today. Keep up the good work man!

  • @jagroop31521
    @jagroop31521 8 років тому +387

    This is called teaching skills , explained complex topi in simple way like int i =0;. Great job!!

    • @purpleice2343
      @purpleice2343 8 років тому +2

      *TRIGGER WARNING, ARGUING FOR THE SAKE OF ARGUING, it is also rhethorical question, tutorial is good*
      How am I supposed to know what int is and why I need ; at the end of line if I never looked at code before nor know what anything means?

    • @gkjnsdfg454
      @gkjnsdfg454 8 років тому +46

      If you don't know what an int is or what the semi colon is for you shouldn't be learning about events and delegate...in fact you should be learning the absolute basics if you don't know what either of them are for. It would be like trying to learn to run, yet you can't even crawl..

    • @purpleice2343
      @purpleice2343 8 років тому +4

      Daniel Rosenbrock You shouldn't be on internet if you take everything seriously, fuck off.

    • @gkjnsdfg454
      @gkjnsdfg454 8 років тому +46

      Mate I encounter many idiots on the daily just assumed you were one of them...now I know you are one of them :)

    • @JordanMetroidManiac
      @JordanMetroidManiac 7 років тому +5

      +Daniel Rosenbrock There wouldn't be any arguing if you just explained to him what they do instead of criticizing him. It's as simple as saying, "Semicolons indicate the end of each line. Ints are integers."

  • @ebayoscorner5512
    @ebayoscorner5512 4 роки тому +1

    After three years in C#, I finally understand events and Delegates.....I have to go and refactor some codes....Many thanks Mosh......Greetings from Nigeria

  • @scotmcpherson
    @scotmcpherson 3 роки тому +1

    This is probably the best tutorial on events and event handlers....all the other's just whip right through each concept and it's nearly impossible to follow unless you already understand it...in which case you don't need the tutorial. You take the time to explain what each thing REALLY IS and the HOW and WHY that thing is important for creating a successful event.

  • @JedaiSaboteur
    @JedaiSaboteur 6 років тому +4

    I've struggled with delegates and events for a long time and this is the tutorial that drove it home for me.

  • @shawnemartin3410
    @shawnemartin3410 8 років тому +5

    This is great! I really appreciate that you took the time to first show the 'formal' way of doing it then showing the shortcut.. most would just show the shortcut!

  • @greenbear9790
    @greenbear9790 2 роки тому +2

    Even 7 years later after this video has been uploaded, I want to notice you that there are many people who are still confused about it. and there are many books and tutorial videos on youtube, but there is no such tutorial video that explains how to use it and why it's used that well and simple. This is one of the best and awesome tutorials I've ever met. thanks to your video, their people never need to buy a book for it.

  • @Andre-wu9fe
    @Andre-wu9fe 5 років тому +2

    To be honest, I never expected a tutorial this good when I felt like reading up on delegates and events again after feeling like I lacked in this area.
    This video was incredibly helpful, and explained the topic in a simple and the most uncomplexed way possible.
    Subscribed. Thank you.

  • @biggs6466
    @biggs6466 Рік тому +10

    Years after the fact and this is still the best video that explains this subject. Thank you so much for your simple, no-nonsense explanation and easing the viewer into the more complex subject matter only *after* explaining the absolute basics.

  • @obo6261
    @obo6261 3 роки тому +7

    Dude this tutorial is sick, thank you so much. As a less experienced programmer, explaining this programming concept in detail without a heap of jargon made this superrrrr accessible

  • @anhtuanle8318
    @anhtuanle8318 2 роки тому +1

    Man, my teacher spent hours explaining this, and i couldnt seem to grasp it, but with just merely 30mins of your video, i got it, thanks bro, appreciate it, this is simplicity at its finest

  • @datkidkizzle
    @datkidkizzle 7 років тому +6

    This is by far the best and most complete introductory tutorial for Delegates and Events that I have ever seen. You did a fantastic job of explaining all the different aspects of events, why they are useful, and I love how you started from a simpler design and then went back and added some more to it.

  • @sensans5238
    @sensans5238 2 роки тому +3

    This actually helped me a lot, I have been struggling for hours.
    So simple and straight to the point.
    Thank you very much!

  • @MrToksvienas
    @MrToksvienas 7 років тому +135

    helped me instantly man!! Now I can see!!!!!!!!!!!!!!!!!

    • @phjorland
      @phjorland 7 років тому

      Very clear, thank you very much! Keep making videos like this- many, many thumbs up will follow

    • @walkercase1836
      @walkercase1836 7 років тому

      Same, I looked all over the MSDN website and it just didn't explain anything well. Thanks a ton man!

    • @nailalzuhairi2690
      @nailalzuhairi2690 7 років тому +1

      hmmmm , so what would you then say if u watch his Video about INTERFACES, showing that so many books and youtubers teaching the developers false concepts like ( INTERFACE is used for Multi-inheritance )..
      If you are one of those who thing the INTERFACE is so , so I would strongly recommend you to watch his legendary Course "C# Intermediate Classes, Interfaces and OOP"

    • @crabsynth3480
      @crabsynth3480 5 років тому

      Best Comment Ever ! :P

  • @ThreeBeerMinimum
    @ThreeBeerMinimum 5 років тому +1

    OK, by far the best freaking Teacher out there. You took something complex and broke it down. I will be purchasing your course SIMPLE BECAUSE YOU DESERVE IT! whether my or my co-workers need it or not - you're getting it!

  • @jasonchu852
    @jasonchu852 4 роки тому +1

    It is the best tutorial on c# "Events and Delegates" that I've ever seen!

  • @lgfdecv4133
    @lgfdecv4133 7 років тому +3

    This video has solved my question very well,I have been confused about events and delegates for several months and i try to understand them by reading books,but it is not easy to understand them fully until i meet this video, thank you,Mosh,Good job!

  • @mgeorgescu
    @mgeorgescu 9 років тому +13

    More C# tutorials sir, you are amazing.

  • @UmeshKumar-ox3zp
    @UmeshKumar-ox3zp 7 років тому +1

    At last I found one video which really explains what delegates and events are all about. I owe to you for this great video, Mr. Mosh.

  • @ismaelsanchez3492
    @ismaelsanchez3492 3 роки тому

    I’ve seen many videos to try understand Events and Delegates, I can say this is the most clear, understandable and practical of them all. Congrats!

  • @WholeNewLevel2018
    @WholeNewLevel2018 8 років тому +7

    This is the Best Video on Events and Delegates .......
    Thanks So Much ... and Pls keep up .....

  • @hikkenwayans
    @hikkenwayans 8 років тому +13

    EXCELLENT TUTORIAL!!!

  • @k4kfh
    @k4kfh 5 років тому +1

    This saved my bacon. Thank you so much!!! I was so confused, especially about delegates, but you explained the relationship and all the syntax perfectly in simple examples without 100 lines of confusing extras.

  • @MelechFreedman
    @MelechFreedman 7 років тому +2

    I finally understand events!! Your amazing. I've Been programming for over ten years and avoiding events for as long as I can. Now I can create true uncoupled code.
    I've subscribed and set alerts!!!!!! Thank you!!!!!

  • @gunting
    @gunting 5 років тому +3

    Holy cat, this is the most clearest and easiest explanation to follow

  • @patz540
    @patz540 8 років тому +4

    This was amazing exhibition of using delegates and events with a superb real time example.Amazing work.You have a new subscriber to your list :)

  • @kitsVideo
    @kitsVideo 8 років тому +1

    Absolutely amazing tutorial! This tutorial allowed me to implement drag and drop functionality of objects embedded in controls in my c# application. Thanks!

  • @sinanmuhamedagic6475
    @sinanmuhamedagic6475 4 роки тому +1

    was watching this video 1 hour before an uni deadline. you've saved me. thank you.

  • @vipulzambare5329
    @vipulzambare5329 9 років тому +12

    Best video to understand events and delegates.. Thanks!!!

  • @viktoradamsky8319
    @viktoradamsky8319 8 років тому +4

    The best explanation I've ever seen on UA-cam on this topic!!! Thanks! Cheers from Russia!

  • @pmcgktr
    @pmcgktr 3 роки тому +2

    I've been working on a feature in an app I'm doing for a client and literally spent 10 hours of jiggery pokery in the code with nothing working. 2/3rds of the way through the video and with a little tweaking I got the feature working!! 😭 Thank you so much you are a god send!!!!! 😭

  • @murphyochuba5340
    @murphyochuba5340 4 роки тому

    This is unarguably the best video I have seen on C# events and delegates. Very detailed and explanatory!

  • @douglascristhian7178
    @douglascristhian7178 9 років тому +3

    Nice job! congrats from Brazil!

  • @lucaschambe
    @lucaschambe 5 років тому +3

    This tutorial was extremely helpful

  • @Jolnichek
    @Jolnichek 8 років тому

    I just made it through the course ..slowly... took hour and a half following along and making notes etc...I can actually say I completely understand this material. The cool thing is that you seem to anticipate listener questions as you teach. Just when I seemed to be getting a little confused you added the precise depth needed to bring me right back on course. Thank you!

  • @jonathantanu2209
    @jonathantanu2209 7 років тому

    Thank you so much for explaining the concept of event-driven development utilizing delegate in C#. It has been a stressful time trying to understand what delegate is for and now I understand it. Once again, thank you.

  • @pebito
    @pebito 8 років тому +4

    Awesome! Thanks for posting this. Gotta watch it again a few times to get the hang of it though :)

  • @SantoshMishra-rw6fy
    @SantoshMishra-rw6fy 8 років тому +3

    Very nice video, hard work is done to help others.Really different perrsonality

  • @ArmaghanUljamil
    @ArmaghanUljamil 8 років тому +1

    Awesome video. I always gets confused when defining and raising events in C#. You have explained it very simply!! great job.

  • @et379
    @et379 9 років тому

    This video is great! I was reading so much on the internet about this, but the examples used, were not explained step by step as you do. Now I finally understood how to use events correctly and also learned a bit about delegates. Thanks!

  • @akisey1
    @akisey1 7 років тому +47

    This is some top quality teaching! Subscribed! +=

  • @MaamuBhanjiVines
    @MaamuBhanjiVines 3 роки тому +4

    Events/Delegates is asked in every .NET interview and I have always shied away from this topic. I have an interview tom morning and can't wait to explain this exact same thing to the interviewer :p Thanks Mosh!

    • @alexisbarrette7652
      @alexisbarrette7652 3 роки тому +3

      So how did you do? Were you asked about delegates during the interview?

    • @Gauravkumar-jm4ve
      @Gauravkumar-jm4ve 3 роки тому

      Yea same with m I also shy from delegates

    • @MaamuBhanjiVines
      @MaamuBhanjiVines 3 роки тому

      I was able to defend my hold on events/delegates this time. Practical examples do help 👍

  • @wdujsub7902
    @wdujsub7902 3 роки тому

    Excellent explanation! I had just a vague idea about how events come into existence and how they work, but I had no problem implementing events into my project and understanding it throughly after the video. The explanation was so clear that there was no need to pause, because everything was put so simply that it seemed that I knew it all along. Thank you.

  • @ashishbhardwaj5908
    @ashishbhardwaj5908 9 років тому +1

    Mosh. You are a genius. In my entire career I didn't see so much easily explained video on such confusing subject Event and Delegate. Good Job...

  • @Thoscellen
    @Thoscellen 7 років тому +8

    Same as many other, you made Delegates and Events Crystal Clear to me :D. But, why have you used EventHandler over Func and Action ? What are the Pro and Cons ?

    • @donfeto7636
      @donfeto7636 5 років тому

      Thoscellen cuz of argument bro sender and eventarg are only in eventhander fun action predicate related to linq i think

  • @MasterTeeee
    @MasterTeeee 5 років тому +13

    To expand on this quickly:
    delegate = More or less a variable, but rather than storing data, it stores one or more methods, provided they adhere to the exact signature.
    event = Expands on delegate to provide protection for malicious code potentially being run... Things like the delegate being overriden or overloaded, and a few other things like that.
    Technically, this can all be done without using the event keyword at all. You can just add the other classes [the subscribers] to the delegate method, and when the publisher calls the delegate method, it runs through every method that has been stored in it.
    Just to give an actual explanation of what's going on here...

  • @InfectionSaarg
    @InfectionSaarg 8 років тому

    This is one of the nicest and well-explaining videos regarding programming in C# that I've found on UA-cam. Would even say that it's Pluralsight-level, although it's free to watch. Thank you very much, keep up the good work!

  • @marcu54h
    @marcu54h 5 років тому +1

    Well recorded video. Voice isn't tiring. I watched all ads without shortcuts (not happens too often) to support the author. Thank You!

  • @AonyjsViolmlar05
    @AonyjsViolmlar05 2 роки тому +4

    If you were my college teacher i'm probably a software architect now.

  • @newandroidfan
    @newandroidfan 3 роки тому +7

    Damn, you've taught this topic in less than 15 minutes and Tim Corey couldn't even do it in 40 minutes. Honestly, I'm disappointed in how Corey chose to explain this topic and Tim seems like he doesn't plan his videos, at least when he's trying to explain a intermediate concept.

  • @mindblower113
    @mindblower113 8 місяців тому

    I don't remember I learned that much information within a 30 minute video with ease. Thanks big man!

  • @owhondaowhonda-wopara509
    @owhondaowhonda-wopara509 6 років тому

    Thank you very very very much Mosh!!!! After lots of searches, this video goes straight to the point in a very simplified manner. You are awesome.

  • @saifmuslim9376
    @saifmuslim9376 8 років тому

    I don't have better words than what Viktor said "The best explanation I've ever seen on UA-cam on this topic!!! Thanks! Cheers from UK"

  • @ahmedelwa2000
    @ahmedelwa2000 4 роки тому

    و الله يا موش أي حد بيرشح أي حاجة من ناحيتك بفتحها و اتعلمها و أنا مغمض و كل مرة مش بتخيب ظني ♥
    شكراً يا موش
    Thank you mosh ♥

  • @qram04
    @qram04 8 років тому

    This is by far the best video that explains Delegates. i understand it much better now. Thanks

  • @poboyinsamsara
    @poboyinsamsara Рік тому

    Ive been trying to get a clear explanation of how events work for weeks. Best explanation I have found. Thank you.

  • @kenc4208
    @kenc4208 7 років тому

    Best material on Events and Delegates i have watched on here. Very clear and gets to the point!

  • @Zergosss
    @Zergosss 9 років тому

    This is the best tutorial on Events & Delegates available anywhere on the internet. Thank you for sharing your knowledge.

  • @robertkak9029
    @robertkak9029 7 років тому

    This tutorial is awesome! after looking into heaps of articles, finally found the one that made me understand it. Thanks!

  • @patrickhitch
    @patrickhitch 3 роки тому +1

    This was awesome video. I have watched several other tutorials on this topic, but none of them explained it in a way I could understand for the purpose I had in mind (not a GUI application). Your video seemed to be tailored to the way I think and absorb information. Thank You!

  • @Shamikix
    @Shamikix 8 років тому +1

    Great video! I was very confused about the difference between Delegate and EventHandler, thank you for clearing this up.

  • @Trio_In_Dubai
    @Trio_In_Dubai 8 років тому

    The best video lesson about C# programming I've ever seen. Now i'm reading Andrew Troelsen Pro. C# and after i read that topic in my book i was little bit confused. I wached many videos about that in russian language, cause i'm not wery good in english. Then I saw that lesson and now it is clear. Thank you! I'm subscribing.

  • @ghazwan2568
    @ghazwan2568 6 років тому

    You were born a teacher man, my absolute favorite instructor and one of my reasons to pick .Net stack because you explain it very well
    greetings from Syria.

  • @rajtilak8841
    @rajtilak8841 6 років тому

    Really glad I found this video. One of the best tutorials on delegate and events.

  • @flabberdog
    @flabberdog 4 роки тому

    You made this click instantly in my head. Much better than the paid tutorials!

  • @mrtalukdarr
    @mrtalukdarr 2 роки тому

    Viewing it in 2021 really saved me a lot of effort with a lot of things in Unity, thanks a lot!

  • @thefivedog
    @thefivedog 9 років тому +1

    A great job in making it understandable it has really helped me the best I've seen. Thanks!

  • @nithinchandran7959
    @nithinchandran7959 6 років тому

    After one year of programming, got the idea of events and delegates just a few minutes ago. Great teaching Mosh

  • @sudheshg
    @sudheshg 9 років тому +1

    thank u mosh . now i have clearly understood clearly what is the use of event handler and delegates to write a loosely coupled events for pub / sub pattern.

  • @seanpenn6994
    @seanpenn6994 2 роки тому +1

    Bro you have given me a new life by explaining this video on delegates and classes and resharper..i am so grateful..i wish i had the confidence to check this video out sooner..but i am hoping with your blessings i can find good work in software again..just low on confidence the last 2 and half years after losing my family and now getting to see my son once a week and for christmas and new years..you saved my life bro...grateful..god bless you...sorry for being overdramatic but such is life now..parents are the only ones who care about me and my son

  • @JohnSmith-ox3gy
    @JohnSmith-ox3gy 3 роки тому

    Spent like 3 hours really confused. Thank you very much.

  • @kryswallbank8608
    @kryswallbank8608 6 років тому

    Thanks for a great tutorial, Mosh! It was informative enough to make me buy your Visual Studio tips and tricks!

  • @MyUTube2312
    @MyUTube2312 8 років тому

    Awesome video Mash! I got rid off confusion around events & delegates after seeing your video only!

  • @elineoosterloo3555
    @elineoosterloo3555 5 років тому

    There are so many tutorials that don't explain and just 'do'. Thanks for really explaining, I learned a lot.

  • @patrickhe6978
    @patrickhe6978 8 років тому

    you are just amazing, man! so clear, vivid and you explain things in a proper speed. English is not my first language but I can understand you just fine.

  • @amantlemashele5719
    @amantlemashele5719 3 роки тому

    The 4th tut I watched tonight and FINALLLLLLLY this made sense, thank you Mosh!!!

  • @p3rks
    @p3rks 7 років тому +1

    Finally I understand how these work.. Life save man, thanks! Subscribed.

  • @AJ-xd2wt
    @AJ-xd2wt 3 роки тому +1

    studying c# in school now and could not get this right, you explain this so much better! thank you for the simple explanation.

  • @p.philippeaudet4608
    @p.philippeaudet4608 8 років тому

    I loved the clean, clear explanation and the speed was perfect. A beautiful ability to deliver. I would love to see a tutorial on serializing and de-serializing classes

  • @TomkhaDev
    @TomkhaDev 4 роки тому

    Great tutorial, especially with showing the exact thing the EventHandler classes accomplish it finally clicked for me.

  • @Foodie_Yaatra
    @Foodie_Yaatra 8 років тому +1

    Great! I am very happy that I finally understood Events and Delegates. Thank you so much Mosh.

  • @mbb720
    @mbb720 4 роки тому

    Man, it took me about an hour and a half to finish this because of all my rewinding and note taking... but I understand it! Great video!

  • @v0id_d3m0n
    @v0id_d3m0n Рік тому +1

    Thank you so much! This was so clear and in-depth, and I'm excited to start using events now!! :)

  • @vamsi8669
    @vamsi8669 7 років тому +1

    Finally and Finally I am able to get hold of events Thanks!!!

  • @alih4341
    @alih4341 Рік тому

    I have seen many Video about Events and Delegates but i found this one the best one

  • @MrHarishchand1980
    @MrHarishchand1980 9 років тому

    Awesome and this is the best video tutorial about Events that i have ever seen. It clears all the confusion about Events. Thanks Mosh.

  • @nomanali5220
    @nomanali5220 6 років тому

    What i like for this guy, is doing things in super simple way, making complicated situations very easy.

  • @petrab.7030
    @petrab.7030 3 роки тому

    Excellent! You've got a new subscriber. Tutorials like this one save a lot of time! Thank you!

  • @joro353
    @joro353 7 років тому

    This is by far the best explenation of events and delegates. Great job Mosh!

  • @kiransoftind
    @kiransoftind 3 роки тому

    Love you Mosh. excellent. i've purchased many of your videos on your website. no parallels.

  • @ahmedhani555
    @ahmedhani555 2 роки тому

    @Programming with Mosh i watched +6 videos trying to understand events + uni scripts... and couldn't understand it. And this video made it so simple and easy

  • @bahozm7214
    @bahozm7214 7 років тому

    This video was more simpler than most of the other videos on delegates and events that I have seen. Thanks!!!

  • @klsjdflksjfd
    @klsjdflksjfd 3 роки тому

    Thank you so much Mosh. This is the best delegate/event tutorial for C# I have seen. I had to watch the video twice but at the end of the second watching I had a strong understanding of these concepts. Thank you!

  • @tccoder3547
    @tccoder3547 5 місяців тому

    Patrick! This beginner C# series is awesome! I love this! I didn’t realize you could is a method in the ternary operator! ❤

  • @user-xg7hi5mh3g
    @user-xg7hi5mh3g 3 роки тому

    I've watched a lof of Videos learning c# ididn't got the Meaning of Delegate, Events before, but Now its more Clear and simple Thank u so much and i had never make a like for a video before but u absolutelry deserve it

  • @potosthecardinal3493
    @potosthecardinal3493 4 роки тому +1

    The must perfect explanation of what is a delegate!! PERFECT thank you for making this :D