Delegates & Events in C# Explained for Beginners (a little of Event-Driven Development)🔔
HTML-код
- Опубликовано: 21 сен 2024
- 🚀 Join the .NET Web Academy: dotnetwebacade...
➡️ Use code START2024 for 10% off!
🚀 Get the .NET 8 Web Dev Jump-Start Course for FREE: dotnet8.patric...
💖 Support me on Patreon for exclusive source code access: / _patrickgod
🐦 Let's get social on Twitter/X: / _patrickgod
🔗 Let's connect on LinkedIn: / patrickgod
Hey friends! 👋 Patrick here. I wanted to add a quick note to this tutorial. I missed mentioning something important: the built-in generic delegates Func and Action. These are really handy for common scenarios - Func is used for methods that return a value, and Action for those that don't return anything. They often simplify the code compared to custom delegates.
I'll make sure to cover these in more detail in a future video. Stay tuned, and happy coding! 😊👨💻
Patrick
what sit u explain do u know how explain beginner pig
I think a much deeper dive is needed for these concepts (why they exist, what problems do they solve, why use them over something simpler and more direct, etc...) as you're getting into more advanced programming and complexity by implementing them. You typically don't use them willy-nilly.
Great answer. I also think that delegates and events are only useful in certain situations. In this case in was only useful to learn about them. But not a great example of when you consider using them
Try learning rabbitMq without them.. it wont work
You make a very good point that delegates and events are very easy to create and use. Probably under utilized these days. Possibilities for use are endless. Thanks!
Glad I could help! Thanks for your feedback!
as a blazor beginner, your explanation is really helpful. Thanks.
Thanks a lot for your feedback! Glad I could help. 😊
I really like your way to describe the principles in clear understandable ways. Keep going it's great, thanks.
One of the clearer tuto I follow about event & delegates...Thank you so much Patrick !
Very nice explanation 👍 Also that bright light in your background gives a nice fresh look to the video
Thank you! Funny you're mentioning the bright light. It was actually just the sun shining through the window and I thought it was too bright. 😅
I'm taking a class on Coursera and the teacher sucks, I have to look up on the youtube some key concepts they explain badly and you sir knock it out of the park. Thank you :)
I was searching for this easy explaination! Thank you Patrick!!
Question; why should we use explicit delegate over Action for example? I think this has the same functionality, but in one line rather than 2?
Good point! In the given example, using Action instead of a custom delegate like AchievementUnlockedHandler would indeed simplify the code. The choice here was mainly to demonstrate how custom delegates work and how they can be used to create events.
In practical applications, opting for Action is a great idea for its simplicity and brevity, especially for straightforward cases like this. Custom delegates become more useful when you need more descriptive names or complex method signatures. Thanks for pointing this out!
@@PatrickGod Ah, thank you for clarifying. :)
Great explanation! Thank you!
Thanks man, Im a bit rusted on these concepts .. LOL
Anytime! Glad I could help! 😊
Aren't Func and Action a built-in delegates ? I think they are easier to understand than creating custom delegates
Yes, you're absolutely right! Func and Action are indeed built-in generic delegates provided by .NET. They are often more convenient and easier to understand, especially for common scenarios. Func is used for methods that return a value, while Action is for those that don't. Custom delegates are more about understanding the underlying concept and are useful in certain specialized cases. Great observation! 👍
Loving these videos! Could you also please make a Blazor Auto Render Mode CRUD Full Course video?
That's great master Patrick, as a blazor beginer I'm excited? Thank you of lot.
The explanations are clear and I hate the next video.
also a tutorial on the connection of webApi, signalR and Chatgpt🙂
Excellent video. Concise, clear, to the point.
Very helpful and informative. Thanks and keep it up!
Thank you so much!
Patrick you do a great job ! Thanks for another nice explaining video.
Love this! looking forward to the big video. We;re not using .net8 yet but your channel is great to keep up2date or at least in the "know" hehe.
Any chance you could make a .net8/identitity server/ Multi tenant video with a central login system shared client but seperate db for each tenant? Been looking into this this week for some idea's hehe.
good work!
Good Explanation..It would be great if u have included delegates with return type also
Thanks for the wonderful explanation!
i understood properly today abt these concepts.
I like this format.
First event explanation that didn't confuse me
Excellent explanation. Thanks
Thanks
I subscribe ! Hoohoooooo
Good work. Can you please create a video for custom authentication with cookie/local storage/session storage & without identity
great lesson!
Very good!
Very good tutorial
Thanks for the great video Patrick. Is there a way to know if I have subscribed to an event,
Not well explained...
Messy bullshit
dude I don't know yet what a delegate is and you are throwing into my face async/await. Kind of stupid
first video i have seen about events that I fully understood
thx
Also why make your own delegate instead of simply using EventHandler ?