C# Generics Tutorial: Whats and Whys

C# Generics Tutorial: learn why we need generics and how to use them.

Check out my other C# video tutorials:

Events and Delegates

Debugging in Visual Studio

If you want to learn C# more thoroughly, check out my comprehensive C# courses on Udemy:

C# Intermediate: Classes, Interfaces and Object-oriented Programming

C# Advanced: Take Your C# Skills to the Next Level

Clean Code: The Art of Writing Beautiful C# Code

C# Developers: Double Your Coding Speed

Connect with me:







50 responses to “C# Generics Tutorial: Whats and Whys”

  1. Diginess Unknown Avatar

    I don't understand the need for constraints on generics. Why would you use that instead of just telling the method what type it is on the parameter in the signature? For instance: public int getSum(int a, int b) instead of public int getSum(T a, T b) where T : int ?

  2. Daniel Dohne Avatar

    what keyboard do you use? sounds good

  3. Shane Berezowski Avatar

    What would happen at runtime if the Type T didn't have a parameterless constructor and we called DoSomething() to instantiate an object of said T?

  4. Johnny B Avatar

    Very clear, concise and thorough. Thanks a lot.

    I like how you narrate what the code / symbols mean – that really helps a lot.
    That is one thing that for me makes C# a real pain – that it is not easy to read at all because instead of words it uses e.g ":" or "#" to mean something. Apart form being difficult to read, you cannot exactly Google : in C# and find out what it is doing.

  5. Adeel Malik Avatar

    Mosh you are the best instructor i have even studied Thanks a lot ………

  6. yazilimciningunlugu.com Avatar

    Thank you for the tutorial.

  7. sunny sharma Avatar

    Awesome Teacher Sir … Your Really Good 🙂

  8. Mujtaba Avatar

    excellent demo. well done

  9. RealSoft Games Avatar

    @9.20 what is that line called. i cant remember for the life of me.

  10. Boi-Hue La Avatar

    Very helpful explanation. Thanks a lot!

  11. jacob zuma Avatar

    just bought all your C# courses on udemy fundamentals, OOP, and advanced. Thank you so much. honestly the only confusing thing about your courses is how well you explain concepts.

  12. Emmanuel Osinnowo Avatar

    You're very very very extra ordinary and extremely good. You're the best programming teacher I've ever seen.

  13. Sankar Prasad Panda Avatar

    your videos are really informative..
    nice one

  14. shawn129386 Avatar

    Great job. Thanks a lot for this awesome video 🙂

  15. Mattshu Avatar

    If I have a Persons (string name, etc) class to store in a list would it be better practice to use the existing List or make my own generic?

  16. Serg Ko Avatar

    For me is to fast, i'm a student and this is like more for working people! Also sometimes using shortcuts without explanation.

  17. Shai Hulud Avatar

    I'm new to coding – in general, not only in c#. And you're definitively my teacher – you know what you are talking about. What impresses me the most is that you have obviously some sort of didactics to your thematics. Highly appreciate that! Keep doin vids, they're awesome!

  18. Hari Babu Avatar

    Valuable content… Thanks for you hard work making this video and sharing it. Great video !!! Awesome.

  19. Armandas Barkauskas Avatar

    You knowledge is unlimited :o, WOW, well done!

  20. Matthew Chermside Avatar

    Really good job, nice simple examples with clear explanation, better than the textbook I am reading at the moment!

  21. Sergio Masson Avatar

    Amazing video ! Please do some video like this for exception handling. Good job!

  22. akhilesh baldi Avatar

    Mosh you are an awesome teacher ! like the way you make things so simple to understand!

  23. Muhammad Ali Avatar

    I guess you LOVE teaching as you love programming ! you make things clear, clean and enjoyable ! waiting for your new course ASP.NET MVC !!! I hope it will be published as soon as possible 🙂

  24. Danish Sultan Avatar

    dude you are awesome, I learned about so many little things in things which I found very helpful, Thanks a lot 🙂

  25. Adi TheOrigin Avatar

    What shortcut have you used to search file (program.cs)? [time 3:41]

  26. Sheshagiri Pai Avatar

    You know your stuff man, awesome (Y)

  27. Brian Heidrich Avatar

    Your a great teacher! Can't wait for the ASP.NET course!

  28. Nick Vielbig Avatar

    Excellent video. Good pace, clear, and focused.


  29. Daniel Nadkin Avatar

    Great video, thank you!

  30. Rajarathinam Balasaubramaniyan Avatar

    Really Good Just Saw your Video i did not see fully i saw little bit because i am in office so i did not see i see in my Home. You are are a Good Teacher

  31. J Z Avatar

    Thanks for your effort. I will follow you. Thanks

  32. Japheth Jay Avatar

    Beautiful tutorial really love it, if i may ask what is the theme you are using on visual studio?. Really like it will love if you could share that am new to the visual studio environment.

  33. Freethinking Влади́мир Avatar

    This is the second tutorial you have published that I watched. You're doing a damn good job!

  34. Claudio Moraes Avatar

    This is kinda advanced :O

  35. exSnake Avatar

    You should do a tutorial about ICommand interface for WPF, it's annoying like the Events/delegate, i founded that tutorial nice!

  36. Saudagar Ahmed Avatar

    awesome , you should create video on struct vs Classes , and when to use them

  37. Hardgraf TH Avatar

    fantastic. perfect for my interview tomorrow!

  38. Yetimus Avatar

    Thank you sir you are a great teacher.

  39. rhubarbcheese Avatar

    what function has 'this'  on " Book this[int index]"? and I think it would be good to explain what where T : IComparable is, as it does not look like any other code.

  40. Will Harrison Avatar

    this is only my second video of yours to watch, but I have to say they are very high quality and very well done.  keep up the good work and thanks.

  41. Bernát Gyovai Avatar

    2:17 I just made this mistake, and came here accidentally not knowing what "Generics" mean… :3 Shame on me! 😀 Thank you!

  42. Denis Dzhalilov Avatar

    Veru useful! Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *