C# Events and Delegates Made Simple | Mosh

C# Events and Delegates Made Simple | Mosh

Programming with Mosh

9 лет назад

940,618 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Emacid
Emacid - 21.09.2023 18:02

As a junior game dev i can say this helped me a lot. Thanks for your efforts

Ответить
Rahul Raj
Rahul Raj - 18.09.2023 13:46

this is Gold

Ответить
Slend
Slend - 31.08.2023 04:48

man this video was so helpful! thanks so much for this tutorial, it was so simple to follow!

Ответить
Quantum Physics
Quantum Physics - 16.08.2023 20:41

Best instructor

Ответить
Francisco Oliveira
Francisco Oliveira - 13.08.2023 18:18

Thank you Mosh!

Ответить
nfaical3
nfaical3 - 08.08.2023 13:01

Thanks for the easy explanation.

Ответить
Sohail Naseer
Sohail Naseer - 02.08.2023 15:33

In-depth, Easy to understand the Scenario of Events & Delegates, i have seen lots of videos to understand some confusion but this is one of the best to explain this subject.
And obviously, in my Software Engineering life, i always ping Sir Mosh to understand solutions in-depth.

Ответить
rya076
rya076 - 25.07.2023 01:12

Thank you for this course... it's very easy to understand.

Ответить
Rounak Sartaliya
Rounak Sartaliya - 09.07.2023 22:32

amazing video , clear concepts!!!!!!!!!!11

Ответить
Kopil Kaiser
Kopil Kaiser - 08.07.2023 13:35

To shorten and make the code more concise:

At time of invoking the event we can do this =>

VideoEncoded?.Invoke(this, EventArgs.Empty);

On the above code,
The "?" Is the null checking operator which won't invoke the event unless it is not null. And invoke is same as writing VideoEncoded(); but we need the invoke because we are checking the null on the event.

Instead of the checking with != null.

Ответить
Курмангазы Утегенов
Курмангазы Утегенов - 05.07.2023 09:08

Hello, Mosh! Thank you for lessons! Could you please make subtitles available? English is not my native language, and I would find it more convenient to have subtitles available for reading. Thank you in advance!

Ответить
MajorSquiggles
MajorSquiggles - 03.07.2023 14:53

Off to a really bad start with the example. I'm not a video editor so trying to explain it in terms of video editing is pointless. You also only say it's meant to save time on recompiling code, but code only takes a few seconds to compile so I don't see why we are using such a complicated process to save a literal second of time. I'm sure if you're a seasoned programmer you could probably find use for this, but for beginners or someone trying to learn you've totally failed right out the gate to make sense of this.

Ответить
disreceded (formerly Bob)
disreceded (formerly Bob) - 24.06.2023 01:46

1000th comment

Ответить
disreceded (formerly Bob)
disreceded (formerly Bob) - 24.06.2023 01:46

999th comment

Ответить
aco
aco - 17.06.2023 17:23

Thank you for clear explanations and the informations !

Ответить
Abdullah Al Nayem
Abdullah Al Nayem - 19.05.2023 12:53

Thanks a lot

Ответить
GustavSant
GustavSant - 26.04.2023 17:42

THANKS!

Ответить
poboyinsamsara
poboyinsamsara - 29.03.2023 04:38

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

Ответить
Sergio Duenas
Sergio Duenas - 24.03.2023 00:57

Hey I know this video is old, but this is one of the better tutorials out there! Thanks for making these!

Ответить
Mukhtaar Aziz
Mukhtaar Aziz - 23.02.2023 17:13

Amazing, Thank you Man.

Ответить
Biggs
Biggs - 23.02.2023 15:15

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.

Ответить
pianoZebra
pianoZebra - 23.02.2023 14:41

Crystal clear explanations. Thanks!

Ответить
nathan daniel
nathan daniel - 19.02.2023 17:18

chatgpt recommened me to wwatch this

Ответить
お元気ですか
お元気ですか - 14.02.2023 11:19

Have been searching explanation about this topic. Hopefully I get my 3mins worth spent.

Ответить
Seanus
Seanus - 10.02.2023 06:30

Great video. Really helpful keeping the delegate explicit until the end so that the 'magic' EventHandler<t> made some sense.

Ответить
pradeep siva
pradeep siva - 07.02.2023 12:59

Awesome. Thank you Mosh.

Ответить
B
B - 30.01.2023 21:52

From my understanding
... an event is a reference type variable
... capable of containing multiple method references
... of a specified delegate signature
... which is triggered in a source object.
So it basically is a variable that can trigger multiple methods in one statement.
Right?

Ответить
Rodane Samuel
Rodane Samuel - 25.01.2023 15:28

When you talk about compiling video encoder separate to mail service etc. Are you saying that you would have each class in a separate project, so that when you have to build in the future there doesn't need to be any communication between them?

Or is it building each as a separate dll, that you link in the project. But building a project, even if you add a new class generally you will still need to recompile the project. Just asking for a little clarity on what you meant by only compiling the new class separate to the whole class.

Ответить
Krishna Singh
Krishna Singh - 21.01.2023 09:37

Jhand explanation

Ответить
Sorrel555
Sorrel555 - 10.01.2023 16:25

Very helpful. Subscribed. Teach me to code please 🙏

Ответить
Kopil Kaiser
Kopil Kaiser - 08.01.2023 05:57

Awesome

Ответить
Kopil Kaiser
Kopil Kaiser - 29.12.2022 02:45

Mosh you are the C# boss

Ответить
Zalanta7 gmail
Zalanta7 gmail - 17.12.2022 00:40

C# Events and Delegates Made Complex

Ответить
LGEnt
LGEnt - 16.12.2022 02:47

Is there a subtitle for this tutorial?

Ответить
Ali Raza
Ali Raza - 14.12.2022 23:50

When we already set the Product class as a type to T
Why exactly we need here Generic class when we already assigning it Product class so apparently it does not seem generic any more.
Can someone explain the purpose here to use generic ????

Ответить
Furkan Cengiz
Furkan Cengiz - 14.11.2022 17:04

Thank you Mosh, clearly and well explained. event handlers are exciting !

Ответить
ebrahim mehri
ebrahim mehri - 14.11.2022 09:04

آقای همدانی از زحمات شما تشکر می‌کنم.

Ответить
Jan Lacina
Jan Lacina - 07.11.2022 12:45

Technically is in non-individual (ordinary, where I do not need anything special) case matter if I have own "EventArgs" or I am using the source object to precisely determine which "action" is done?Let's say I have a collection to process and I run it via Parallel.ForEach.

Ответить
Kinga K
Kinga K - 14.10.2022 10:45

Thank you so much, I finally made my first working customised event in c# thanks to you

Ответить
EZ T
EZ T - 10.10.2022 03:22

Really good explanation of how to use an event. Nicely brought it all together when you replaced the initial delegate definition (at the start) with the EventHandler defiinition at the end. The only thing I would add is that many people might not understand the reason to actually use the keyword "event" in the VideoEncoder class. Removing this keyword will result in this code example to still work HOWEVER this keyword is still necessary. (basically it provides protection to the Event so as not to be abused by other outside objects).

Ответить
The Modern Waiter
The Modern Waiter - 07.10.2022 04:56

I review this tutorials two times thank you for your outstanding work Mosh

Ответить
Ryan M.
Ryan M. - 03.10.2022 22:51

Thank you for this video! Delegates and why we use them was a difficult topic to wrap my head around, but this video was a perfect explanation. Very easy to follow and understand.

Ответить
Derelicts
Derelicts - 02.10.2022 23:22

I was trying to learn this from "C# in a Nutshell" book and that was kind of dry.
This was a superb explanation, absolutely perfect teaching Mosh, thank you!

Ответить
metal lords rules
metal lords rules - 24.09.2022 22:00

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

Ответить
Asta
Asta - 11.09.2022 21:12

How often do you use even and delegates in real life?

Ответить
Michael J Lawrence
Michael J Lawrence - 05.09.2022 22:57

midroll in video about a confusing topic (which you acknowledge) = boo. Thanks for interrupting yourself just as I was almost understanding. Now I have to back up.

Ответить
Kanza Naveed
Kanza Naveed - 04.09.2022 11:34

Okay so I was short on time and I had to write a code snippet using delegates and events. I found this 30 minutes video and some others but being aware of the simplicity of Programming with Mosh, I decided to watch this one. And after completing it "I am here to confirm that I now have a very clear and pretty good understanding of Events and Delegates and can write code using them". Hence, proved once again that Mosh Hamedani is one of the best teachers in explaining things at the most easiest level. Thank you so much, God bless!

Ответить
Ali H
Ali H - 26.08.2022 00:31

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

Ответить
Yannick Frögel
Yannick Frögel - 16.08.2022 11:39

One question. I have a class that has an event. Another class needs to know only when it happens and another class needs to know when it happens and one variable of the event class. How would you guys solve this in the best way? One Event with a parameter and one event without or should i make that Event without Parameter and the class that needs the variable directly gets IT from the class?

Ответить
Sameera Navalkar
Sameera Navalkar - 15.08.2022 13:07

Superb... I used to be always confused on tie up between event and delagates and how to invoke it. This video gave a very clear picture. Thank you Mosh

Ответить