C# Generics - What they are, why they are useful, and how to create them

  Рет қаралды 253,544

IAmTimCorey

IAmTimCorey

Күн бұрын

Have you ever used a List of T and wondered what the T meant? Or maybe you heard the term generics but you did not really know what that was or why it was important. Maybe you have been using generics for a while but didn't know you could create your own. Whatever the case, this video is for you. In this video, I am going to lay the foundation of what generics are and what makes them so powerful. Then, we will look at a demonstration I have set up on how you can keep your code dry, better conform to the SOLID principles, and make your life easier by implementing generics a class.
Source Code: leadmagnets.app/?Resource=CSh...
Patreon: / iamtimcorey
Newsletter signup: signup.iamtimcorey.com/
0:00 - Intro
1:33 - Creating a List of T
4:03 - Why not to use ArrayList and why generics are useful
11:10 - Demo app walk through pt1
22:56 - The problem: repetition
28:55 - Solving the repetition with generics; Demo application walk through pt2
47:50 - When to use generics
50:41 - Passing in more than one type of generic

Пікірлер: 503
@marienoellemaltais
@marienoellemaltais 6 жыл бұрын
You are such a great teacher. Many blessings to you. Simplicity is born out of a deeper understanding. Your tutorials are brilliant, like a breath of fresh air.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Thank you for the kind words.
@ValiRossi
@ValiRossi 5 жыл бұрын
I agree. Every lesson is very consistent which helps in the learning process.
@thesophisticatedvelocirapt7320
@thesophisticatedvelocirapt7320 3 жыл бұрын
"Simplicity is born out of a deeper understanding" .........deep And yes, Tim Corey is the best
@octavian9168
@octavian9168 2 жыл бұрын
Glad you're still with us. Sounds like a crazy experience, that tsunami... Hopefully one day I will learn French or find a translated copy of your book. Interesting to see you coding!
@LiakatHossain
@LiakatHossain Жыл бұрын
And his voice as well 😍
@NM-tr1ii
@NM-tr1ii 2 жыл бұрын
You're my fav C# instructor. Period! I don't know what moment or who sparked the idea in your head that you decided to share your knowledge with the world, I'm just grateful that you did :-)
@huzaifatinwala
@huzaifatinwala 4 жыл бұрын
Best C# generics tutorial I have come across. Thanks, Tim. Really appreciate it.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome. Thanks for watching.
@mannys12345
@mannys12345 4 жыл бұрын
Tim, great course. I like the way you explain "why" we would use Generics in real-world scenarios as opposed to just giving us "high-level" examples. Note that this teaching method sets you apart from other teachers. Also, you showed us an example where originally we don't use generics and then where (and why) we would use Generics (code reuse and decoupling logic implementation from actual data types).
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad you found it helpful.
@christianromedahl4456
@christianromedahl4456 4 жыл бұрын
Agree. One of the best teachers that I've found so far. Really clear, in-depth, not going on too fast (like some others just rushing on), so it's easy to follow and grasp. Brilliant! Thanx a lot. :)
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome. Thanks for watching.
@n9434178
@n9434178 6 жыл бұрын
Thank you Tim! This video improved my understanding of the use of generics.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Excellent!
@linukkis
@linukkis 4 жыл бұрын
You're hands down the best teacher I've ever seen. Nothing is left unexplained, everything is always very clear and simple to understand. Thank you so much for inspiring other programmers through your awesome videos!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I appreciate the kind words.
@branislavpetrovic7486
@branislavpetrovic7486 6 жыл бұрын
This is excellent and simple tutorial on C# generics. Thank you for your efforts and sharing your precious knowledge.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I am glad you enjoyed it.
@forresttucker168
@forresttucker168 3 жыл бұрын
I had no problems whatsoever understanding why it was done this way and how generics work, and I forsee it saving me a lot of work in the future. Thanks a lot Tim....
@higherpurpose1212
@higherpurpose1212 3 жыл бұрын
what I iike about your tutorials like this one, is you don't over complicate things and I believe you always consider the level of skill of your watchers, explaining how and why things are done in a certain way. thanks Tim.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad you like them!
@rodolfoeliezer1346
@rodolfoeliezer1346 3 жыл бұрын
The professor who doesn't assume understanding of some specific part of the explanation makes my understanding much better. Thank you a lot Tim Corey, for providing such a good content and yet free. Thanks from Brazil.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You're very welcome! ... from Texas USA
@orcaowlwizco369
@orcaowlwizco369 5 жыл бұрын
Man been watching and liking all your vids. They are solid. As a person finishing up a year's worth of c# classes, I still find your way of teaching really easy to understand, and the tips and way in which you deliver information is extremely helpful. Many thanks buddy!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are most welcome. Thanks for watching.
@volo7
@volo7 3 жыл бұрын
I haven't come across a better teacher for C# programming online. Thank you so much for what you are doing!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You're very welcome!
@andreaskarz
@andreaskarz 3 жыл бұрын
I agree
@neemapranay23
@neemapranay23 3 жыл бұрын
In India today (5th September) we are celebrating Teachers day. And for me, you are one of the best teachers I came across. Happy Teachers Day Tim!!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thank you!
@robertmerritt3284
@robertmerritt3284 5 жыл бұрын
I have no idea how anyone could possibly give this video a thumbs down. Thanks Tim! You are awesome. I'll be heading over to Patreon real soon. Appreciate all you do to make our lives easier and wealthier!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I appreciate the kind words.
@ferrad1
@ferrad1 6 жыл бұрын
Best free C# tutorial videos online ! Thank you Sir ! Keep up the good work !
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Thank you for the kind words.
@mbvisiombvisio1170
@mbvisiombvisio1170 3 жыл бұрын
Very helpful video. Generics explain in a practical way. Good teaching methodology. Not overcomplicated way of sharing your knowledge. Keep it simple Tim!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I am glad it was helpful.
@alikinng8653
@alikinng8653 4 жыл бұрын
This is excellent and simple tutorial on C# generics. Thank you for your efforts and sharing your precious knowledge.Thank you sir!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome. Thanks for watching.
@khaledbudajaja6137
@khaledbudajaja6137 5 жыл бұрын
I have been using generics for a quite long time, but never managed to understand how to make one. you explained it very well. Many thanks Tim Corey
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome! I'm glad I could add to your knowledge.
@madhavmehendale7324
@madhavmehendale7324 4 жыл бұрын
This opened my mind to a lot of things that Ive seen on your other videos but which I did not fully appreciate - until now
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Excellent!
@RahulSharma-ps1rf
@RahulSharma-ps1rf 3 жыл бұрын
Very good teaching, the best part is that first you explain what most of us do and show the best thing. Learnt a lot
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad to hear that
@georgetuccio6053
@georgetuccio6053 Жыл бұрын
Very clever example and code Tim. Just the right amount of complexity. Liked the reflection thrown in too. Thank you.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@adityarane2758
@adityarane2758 2 жыл бұрын
Best Video in Advance Topics Playlist up till now. I loved the generic methods because I faced this problem in my previous organization.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Glad it was helpful!
@thethomasproject
@thethomasproject 2 жыл бұрын
Tim, again, an older but very timeless video. Thanks for the clear explanation on generics!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@abidzahid2974
@abidzahid2974 Жыл бұрын
That is an excellent and simple explanation. I had some confusion about Generic methods, which are cleared now. Thank you.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Glad it was helpful!
@yuriymayyagruzglin1812
@yuriymayyagruzglin1812 4 жыл бұрын
As always - clear, concise, great. Thank you Tim!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@joystanrolan495
@joystanrolan495 3 жыл бұрын
Adicted to IAmTimCorey channel. Learning makes easy when we find the right person who can answer our questions without asking them. You are a Great teacher and your efforts are really amazing. Thank you so much Sir. Love from India
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for trusting Tim with your time.
@charalampost769
@charalampost769 4 жыл бұрын
Thank you for your videos, there are amazing. You help me so much to learn, and your sound and spelling is so clear to make it easy to understand for people that english isnt their native language.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I am glad my content has been so helpful.
@Redpill99
@Redpill99 Жыл бұрын
Thanks Tim for giving so much to the community.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@testthisfordecficiencies
@testthisfordecficiencies 3 жыл бұрын
Great work Tim! Your syllable timing is perfect and I can run your video at 1.25 or 1.5 times and it still seems normal to my fast Brain.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Great to hear!
@SuperLadly
@SuperLadly 2 жыл бұрын
Good one. Restriction and mentioning empty constructor was new to me. Thank you
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@DepressionAlgorithm
@DepressionAlgorithm 4 жыл бұрын
Nice video as always Tim. Just a note on 35:20 for anyone interested in reflection: You can still grab the properties of a class, using reflection, without creating an instance of that class. This will compile and perform the same task: *var cols = typeof(T).GetProperties();* The instance was still needed in Tim's example though, since he's returning instances of that class in the Load method.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Yep, thanks for pointing that out.
@RootofEvilify
@RootofEvilify 4 жыл бұрын
Thank you Tim! I work at company where we use C# and MVVM pattern, I learned some new things from you. :)
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Excellent!
@email195
@email195 3 жыл бұрын
Thanks again Tim for a great tutorial. I actually just used what I learned on a project where I have a method that calls a Web API and was returning JSON. Then I would deserialize it in the calling method into the proper type. Now I just use generics and this method returns the object that I called for. So much nicer. Old code... public static async Task SendRequest(HttpMethod method, string requestUri, object payload = null) which returned the raw JSON string New code. public static async Task SendRequest(HttpMethod method, string requestUri, object payload = null) where T : class which returns JsonConvert.DeserializeObject(responsePayload)
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Great! I am glad it was so useful.
@linux_master_race
@linux_master_race 4 жыл бұрын
I've been working with .NET, and primarily C#, since before it was even publicly available and I still learn great things from your videos. Thank you!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome. Thanks for watching.
@juliusv2073
@juliusv2073 2 жыл бұрын
Some people are born to teach, you one of them. Big thanks
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@andrijapavlovic6322
@andrijapavlovic6322 5 жыл бұрын
Best tutorials on C#! Keep going!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome! Will do.
@torrvic1156
@torrvic1156 11 ай бұрын
Merci bien for your hard efforts to enlighten us Tim! You are an inspiration to start making a good code.
@IAmTimCorey
@IAmTimCorey 11 ай бұрын
You are welcome.
@scottk5083
@scottk5083 5 жыл бұрын
That you very much. Has really improved my understanding regarding this topic. You are an excellet teacher
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome! I'm glad you were able to increase your understanding of the topic.
@pioneer7161
@pioneer7161 2 жыл бұрын
the beauty of this channel is it shows the practical usage of the theoretical concept.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks!
@jasper5016
@jasper5016 5 жыл бұрын
You are the greatest instructor I have ever seen. You are just awesome.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I appreciate the kind words.
@shuvbhowmickbestin
@shuvbhowmickbestin Жыл бұрын
Wonderful content Tim. Kudos to you!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thank you!
@madChileRiver
@madChileRiver 4 жыл бұрын
Another great video clearly explaining an area that is often misunderstood!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thank you!
@patatas.m1317
@patatas.m1317 4 жыл бұрын
You are so good sir, you explain it clearly. Even the topic is pretty advance for me, I can imagine things by your words. Thanks for making this video:)
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@surajnarwate7536
@surajnarwate7536 4 жыл бұрын
Tim , you are fabulous trainer. Keep it up. I learnt, much more from your video.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thank you!
@Stone8age
@Stone8age 4 ай бұрын
This is great. You concisely explained a concept that i originally perceived to be intimidating and confusing. Bravo
@IAmTimCorey
@IAmTimCorey 4 ай бұрын
I am glad it was helpful.
@Linkario86
@Linkario86 5 жыл бұрын
Finaly an example where this is actualy useful. Now I understand the whole thing much better. Thanks a lot!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@luih7314
@luih7314 5 жыл бұрын
You're my hero Timmy Such an emotional video, you killed off Sue Storm :)
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
It was a rough one, but don't forget, Sue is a comic book character. They never really die.
@ahmer9800
@ahmer9800 4 жыл бұрын
very glad i found this video. i've been trying to sort out template interfaces for days!!!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I'm glad you got value out of this video.
@mirogeorgiev7095
@mirogeorgiev7095 3 жыл бұрын
It was very helpful for me. Thank you Tim.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad it was helpful!
@jean-marcblanchet2270
@jean-marcblanchet2270 2 жыл бұрын
Well, thank you Tim for the great content you provide for free to us, the C# developers community. I have an old habit I took when learning C language, a long time ago when I was a student. I always put my checking code at the beginning of my methods, before any declaration or usage of variables and objects. So that I get rid of incorrect or incomplete values before going further, for instance by raising an exception or returning an error code. I don't know if it's a good practice, but I'm sure data is correct after that checking step.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 2 жыл бұрын
Interesting, thanks for sharing that approach.
@VinuP2023
@VinuP2023 6 жыл бұрын
I appreciate all your efforts Sir. Thank you :)
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
You are welcome.
@rosahartanto8055
@rosahartanto8055 3 жыл бұрын
thanks tim corey for the sharing, hopelly continue share for next videos
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
We appreciate you making Tim a part of your development journey
6 жыл бұрын
Thanks Tim, this video help me a lot to understand more about Generics!
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I'm glad it helped you out.
@harag9
@harag9 6 жыл бұрын
Great tutorial, thanks very much for your efforts on these - especially when it's 12:48 AM.. wow dedicated!
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Thanks! That's actually a pretty common time for me to be recording. I only get a few hours a day where I can record right now (from about 10pm to 2am). I am actually working on some soundproofing and other things so that I can record earlier in the day without degrading the sound quality. Once I get that in place, I can record starting at about 9pm. Once I quit my day job (that is based upon the amount of income I bring in from videos), I can record all day long. That will GREATLY increase the amount of content I can put out. That is also when I'll start being able to put out a video per week in other languages that complement C# like SQL, HTML, CSS, JavaScript, etc. My first priority will be C# but once I have more time, I can support developers more fully in the other areas as well.
@bmrreddy2002
@bmrreddy2002 6 жыл бұрын
Tim ,If that's the route you wanna go, I honestly think you need to put out a lot of your content on Udemy and other sites and make them paid courses. Your explanation is just fantastic and you deserve to get paid for it!
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Well, I will be doing more paid courses in the near future (and long-term). I have a few at IAmTimCorey.com but I'll be adding a few more soon. I've looked at Udemy but they really take a lot from teachers (50% plus they set pricing so your $40 course might be sold for $10 without your say). I really don't want to go down that road. I'll stick with my own platform where I can charge a reasonable amount and get about 95% of the asking price. I appreciate the kind words.
@bmrreddy2002
@bmrreddy2002 6 жыл бұрын
IAmTimCorey ah true! See I don't know what their cut is, but yes that's a lot. But you're a real good teacher and would do great doing this full time! Will take some time to get there for sure. Good luck ! :)
@MrGegere
@MrGegere 4 жыл бұрын
Heh, I needed 6 minutes of Your video to understand what I need. Truly great content.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thanks!
@JohannJimenez
@JohannJimenez 6 жыл бұрын
Perfect explanation. Thanks.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I'm glad.
@alexanderspiegel6747
@alexanderspiegel6747 4 жыл бұрын
Here is my “like”, Tim. Thanks for the great lesson.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are most welcome. Thanks for watching.
@kevinrambo
@kevinrambo Жыл бұрын
Good job! I appreciate you posting your videos.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks!
@somethingnotspecified
@somethingnotspecified Жыл бұрын
This was a very helpful tutorial. Thank you!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@ViktorTy
@ViktorTy 3 жыл бұрын
Hey Tim! I am a very big fan of your videos! Thank you for helping me learn C#! I was wondering if you plan to make a follow-up on generics and speak about how we can use generics and dependency inversion together as principles to make dynamic interfaces that we can reuse? I think it is a very interesting and challenging topic that most people would appreciate.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Added to the list, thanks.
@dragonburger5676
@dragonburger5676 3 жыл бұрын
She glad I found this channel!! Thank you Tim!
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
We are pleased you did also.
@prubenheeren707
@prubenheeren707 4 жыл бұрын
Your videos are insanely good. Love it.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
Thank you!
@nelsonluisfreire8969
@nelsonluisfreire8969 3 жыл бұрын
Great video, and correct pace
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks!
@PabloSanDev
@PabloSanDev 7 ай бұрын
Great material, bravo Tim!
@IAmTimCorey
@IAmTimCorey 7 ай бұрын
Thank you!
@MrMakgotla
@MrMakgotla 3 жыл бұрын
wish you could go around the world to teach the teachers how to teach... wow, I feel super happy to have came across your channel. "ke a leboga, thata"(Thank you very much(all the way from RSA))
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@jasonjames1849
@jasonjames1849 2 жыл бұрын
Excellent video, Generics have always been a bit confusing to me and it helps me best when there is a practical demo like in this video. So thanks for that
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@willamsreis9715
@willamsreis9715 3 жыл бұрын
Great lesson, Tim. You've done a great jog teaching us how to handle with C# technology, Thank you so much.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@GabrielBauermann
@GabrielBauermann 5 жыл бұрын
Awesome! What a great lesson. Thank you.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
You are welcome.
@chukwumaesoga5171
@chukwumaesoga5171 3 жыл бұрын
I have always struggled to understand generics and how to use collections and this video just broke it down for me in the simplest way. You are awesome at how you approach topics and i jsut subscribed to you channel so i can learn more
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad it was helpful! Thanks for the sub!
@krishan3515
@krishan3515 Жыл бұрын
Thank you. Very informative. Very well explained.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@gilhooli6685
@gilhooli6685 6 жыл бұрын
Thank you very much. I love this channel and found it very useful. I also love your way of teaching.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
You are most welcome.
@nooraldeenali4628
@nooraldeenali4628 3 жыл бұрын
It's really helpful. Sir, only with your video did I learn why, I have to use generic. Thanks a lot.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Great!
@jeremybourgne7394
@jeremybourgne7394 3 жыл бұрын
Thanks a lot, great example! You've got to love it!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad you like it!
@godfathermikal
@godfathermikal 5 жыл бұрын
This is my 2nd favorite video you've made. :-)
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Awesome! What's the first?
@kimvanasselberg9659
@kimvanasselberg9659 5 жыл бұрын
Now I love generics. Thanks for the great tutorial.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Excellent!
@ademineshat
@ademineshat 5 жыл бұрын
I was busy watching your other Videos, but today was the Time, yay. I've been using a separate class like processor for every model like you said :) where i was doing queries with Dapper and Today was the day when I put them all in one place. I was allways feeling that I'm repeating my self, and I really was! Thank you very much Tim
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
I'm glad you were able to figure that out and improve. Well done.
@ademineshat
@ademineshat 5 жыл бұрын
But still a Tutorial with Generics and Dapper will be great :)
@aaronvaughan2401
@aaronvaughan2401 Жыл бұрын
Very helpful, using reflection in the code is interesting.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Glad it was helpful!
@movsar42
@movsar42 3 жыл бұрын
You are that perfect c# book I was looking for!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Great!
@VinuP2023
@VinuP2023 5 жыл бұрын
Tim, 12,114 views and 418 likes and "0" dislikes as on date, That speaks quality of this video. :)
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thank you.
@marceloleoncaceres6826
@marceloleoncaceres6826 8 ай бұрын
Great example, very useful. Thanks a lot
@IAmTimCorey
@IAmTimCorey 8 ай бұрын
You are welcome.
@pcintra1
@pcintra1 4 жыл бұрын
Thanks for the great lesson Tim!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
My pleasure!
@nafisiancastle
@nafisiancastle 2 жыл бұрын
I learned generics before. But today I learned why and when I should use it. Thank you !
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@gustavoramia
@gustavoramia 6 жыл бұрын
Great video. You really know how to explain things
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
Thank you.
@al-omdaahmed3191
@al-omdaahmed3191 4 жыл бұрын
you are a great tutor , thank you again and again for these videos
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@raguramanmanokaran1824
@raguramanmanokaran1824 3 жыл бұрын
Simple and Superb !!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thank you! Cheers!
@azizbekibnhamid642
@azizbekibnhamid642 Жыл бұрын
Great job!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks!
@longuinni
@longuinni 6 жыл бұрын
Really nice. You make C# much easier to understand.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
That's the goal. I'm glad it is working.
@longuinni
@longuinni 6 жыл бұрын
IAmTimCorey yes, it's working. It will be great if you make a mvvm series. I don't know why I can learn mvvm.
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I do have an add-on course to my C# Application from Start to Finish course where I replace the WinForm UI with WPF (using Caliburn Micro and MVVM) if you want to check that out: iamtimcorey.com/courses/tournament-tracker-wpf-user-interface/
@longuinni
@longuinni 6 жыл бұрын
I don't know why I didn't see this course before! Thank you Tim!
@fsoria
@fsoria 3 жыл бұрын
this is the best tuts, very clear
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I am glad my content is helpful to you.
@aaronvaughan2401
@aaronvaughan2401 Жыл бұрын
Very helpful, thank you.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@francogiulianopertile279
@francogiulianopertile279 2 жыл бұрын
Great explanation, greetings from Argentina
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@zulhishamtan4308
@zulhishamtan4308 3 жыл бұрын
Yes, Generic is useful, it can reduce duplicate code. Thank you very much. Very precise explanation.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome!
@NOCKSCITNEY
@NOCKSCITNEY 2 жыл бұрын
Hi Tim. Recently found you and even being an established coder, I feel I've learnt lots from you over the last week. Quick question. I too have used Generics for SQL connectivity to scale down a helper class I had for creating and reading parameter in SQL queries, going from a method for each type to generic methods to encompass all of them. Thinking about your discussion in this video about doing it also for the SQL connectivity portion, would Generics work for a "void" method declaration as well as where a return type is needed? My thought on this without experimenting of course, is that you'd have 2 methods, one where there is a return type and then another where there isn't? Would that be the case?
@RockmanR
@RockmanR 4 жыл бұрын
Your videos are clear and simple and I enjoy watching it. I've tried Pluralsight before and all of the teachers so far (like 4 people) were unnecessarily complicating stuff and were very formal and boring. Thanks a million Tim.
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
I appreciate the kind words.
@gleisonsubzeroKZ
@gleisonsubzeroKZ 3 жыл бұрын
thanks a lot for this excellent and wonderful tutorial about generics. I made some changes on reflection parts and I would share with you guys: public static List LoadFromTextFile(string filePath) where T : class, new() { var lines = System.IO.File.ReadAllLines(filePath).ToList(); List outputList = new List(); var properties = typeof(T).GetProperties(); if (lines.Count < 2) throw new IndexOutOfRangeException("The file was either empty or missing."); // Splits the header into one column header per entry var headerColumns = lines[0].Split(','); lines.RemoveAt(0); foreach (var row in lines) { T entry = new T(); var rowValues = row.Split(','); foreach (var column in headerColumns.Select((columnName, columnIndex) => new { columnName, columnIndex })) { var propertyRef = properties.SingleOrDefault(property => property.Name == column.columnName); if (propertyRef != null) { object typedValue = Convert.ChangeType(rowValues[column.columnIndex], propertyRef.PropertyType); propertyRef.SetValue(entry, typedValue); } } outputList.Add(entry); } return outputList; } public static void SaveToTextFile(List lstData, string filePath) where T : class { List lines = new List(); if (!(lstData?.Count > 0)) throw new ArgumentNullException("data", "You must populate the data parameter with at least one value."); var properties = typeof(T).GetProperties(); lines.Add(string.Join(",", properties.Select(c => c.Name))); foreach (var row in lstData) { var rowValues = properties.Select(c => c.GetValue(row)).ToList(); lines.Add(string.Join(",", rowValues)); } System.IO.File.WriteAllLines(filePath, lines); }
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks for sharing.
@mindawakening3873
@mindawakening3873 5 жыл бұрын
Absolutely awesome!
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Thanks!
@jayjayjaythebrand
@jayjayjaythebrand 6 жыл бұрын
Everyone on here has benefitted from Tim in one way or another. Please subscribe to this man's Patreon, even if it's just the $1, that's nothing compared to the value he provides us for FREE! Support this guy!!!
@IAmTimCorey
@IAmTimCorey 6 жыл бұрын
I appreciate the kind words and the support.
@StreetBladerBloke
@StreetBladerBloke 5 жыл бұрын
Or sign up his courses to support him..
@mohammadjavadtavakoli7977
@mohammadjavadtavakoli7977 4 жыл бұрын
Thank you Tim!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@betozurita151
@betozurita151 4 жыл бұрын
Great Tutorial. Thanks!
@IAmTimCorey
@IAmTimCorey 4 жыл бұрын
You are welcome.
@dansolarta8937
@dansolarta8937 5 жыл бұрын
am impressed, i wanna do more generics with different class properties.
@IAmTimCorey
@IAmTimCorey 5 жыл бұрын
Great!
C# Events - Creating and Consuming Events in Your Application
1:09:13
Delegates in C# - A practical demonstration, including Action and Func
1:09:11
Ну Лилит))) прода в онк: завидные котики
00:51
[柴犬ASMR]曼玉Manyu&小白Bai 毛发护理Spa asmr
01:00
是曼玉不是鳗鱼
Рет қаралды 52 МЛН
Hot Ball ASMR #asmr #asmrsounds #satisfying #relaxing #satisfyingvideo
00:19
Oddly Satisfying
Рет қаралды 21 МЛН
When someone reclines their seat ✈️
00:21
Adam W
Рет қаралды 19 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 738 М.
microsoft recall is an absolute dumpster fire
9:34
Low Level Learning
Рет қаралды 16 М.
C# generics ⁉️
5:33
Bro Code
Рет қаралды 67 М.
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1 МЛН
Ну Лилит))) прода в онк: завидные котики
00:51