What are Generics? (C# Basics)

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 เม.ย. 2020
  • 🌍 FREE C# Beginner Complete Course! • Learn C# Beginner FREE...
    🔴 Watch my Complete FREE Game Dev Course! 🌍 • Learn Unity Beginner/I...
    📝 C# Basics to Advanced Playlist • C# Basics to Advanced
    🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses​
    👍 Learn to make awesome games step-by-step from start to finish.
    🎮 Get my Steam Games unitycodemonkey.com/gamebundle
    ✅ Learn all about Generics in C# and how to use them
    Learn Unity in 17 MINUTES!
    • Learn Unity in 17 MINU...
    Learn C# BASICS in 10 MINUTES!
    • Learn C# BASICS in 10 ...
    What are Events? (C# Basics)
    • What are Events? (C# B...
    What are Delegates? (C# Basics, Lambda, Action, Func)
    • What are Delegates? (C...
    What are Interfaces? (C# Basics)
    • What are Interfaces? (...
    What are Generics? (C# Basics)
    • What are Generics? (C#...
    What are Loops? (C# Basics, for, while, do)
    • What are Loops? (C# Ba...
    Unity Tips in 10 MINUTES!
    • 12 MORE Unity Tips in ...
    Unity Basics for Beginners
    • Learn Unity in 17 MINU...
    Grid System in Unity
    • Grid System in Unity (...
    How to handle Events in Unity DOTS
    • How to handle Events i...
    What are Delegates? (C# Basics)
    • What are Delegates? (C...
    Constraints on Generic Type parameters
    docs.microsoft.com/en-us/dotn...
    If you have any questions post them in the comments and I'll do my best to answer them.
    🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
    See you next time!
    📍 Support on Patreon / unitycodemonkey
    🤖 Join the Community Discord / discord
    📦 Grab the Game Bundle at unitycodemonkey.com/gameBundl...
    📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
    #unitytutorial #unity3d #unity2d
    --------------------------------------------------------------------
    Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.
    I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
    You can see my games at www.endlessloopstudios.com
    --------------------------------------------------------------------
    - Website: unitycodemonkey.com/
    - Twitter: / unitycodemonkey
    - Facebook: / unitycodemonkey

ความคิดเห็น • 167

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  4 ปีที่แล้ว +30

    🌍 FREE C# Beginner Complete Course! th-cam.com/video/pReR6Z9rK-o/w-d-xo.html
    🔴 Watch my Complete FREE Game Dev Course! 🌍 th-cam.com/video/AmGSEH7QcDg/w-d-xo.html
    📝 C# Basics to Advanced Playlist th-cam.com/play/PLzDRvYVwl53t2GGC4rV_AmH7vSvSqjVmz.html
    🌐 Have you found the videos Helpful and Valuable?
    ❤️ Get my Courses unitycodemonkey.com/courses or my Steam Games 🎮 unitycodemonkey.com/gamebundle
    Generics! Such a useful C# feature! Have you used them before?

    • @KineticCode
      @KineticCode 4 ปีที่แล้ว +3

      Oh boy! I've been making a card game(looks pretty great so far) and I can't count how many times I asked myself "God I wish I could just write a function that takes and returns any type." This video and your video on delegates have turned my life upside down and probably saved me dozens of hours of slamming my head on my keyboard. cheers!

    • @rickmemmer5625
      @rickmemmer5625 ปีที่แล้ว

      As top-notch as it gets! And I would add: There's a ton of over-the-top praise going on today (movies, politics, etc.) -- where excellence is not established in the craft, but rather the perception of what people think they see. This is pure craft -- and worthy of every bit of praise you get. I'm looking forward to watching more -- and many thanks for enlightening me. It's so good I can't believe some of this stuff didn't fully register before. But it's a testament to your work that I'm kicking myself. Thanks again!

  • @erz3030
    @erz3030 4 ปีที่แล้ว +108

    Amazingly helpful lesson! I enjoy how you begin with the "lazy/incorrect" implementations before the 'proper' version. It definitely helps understand why you would want to implement the solution.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +28

      Thanks! I do work hard on the structure of the videos!

  • @DxBALLxD
    @DxBALLxD 4 ปีที่แล้ว +56

    I love hearing tutorials say "the Func"
    Da funk.

  • @chuckdude514
    @chuckdude514 2 ปีที่แล้ว +19

    Really had a great time in learning these "unused" (in almost every tutorial) concepts. This should be the first playlist that everyone should go through in my opinion, otherwise they will end up just copying and pasting stuff without understanding them so much and having a hard time in creating their own clean and optimized code.
    Just so you have an idea, I've been using Unity for one and a half years and never knew about these C# features until I found your channel (grid tutorial)! Hell, I didn't even knew that there were constant updates and discussions around programming languages! Learning about core concepts like these and good practices is truly understimated in the coding community. This opens so many doors into creating new things.
    Anyways, I just wanted to thank you for showing people how much there is to learn besides simply implementing some specific features in a game! I think that once I master these concepts, I'll be able to have my games made quicker and more optimized!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว +5

      Thanks for the kind words! Yup C# has tons of awesome features that a lot of people are seemingly afraid to use or just don't know about but if you take the time to learn them it will improve your code massively and make you much more productive.
      Best of luck in your learning journey!

  • @morsheddld
    @morsheddld 3 ปีที่แล้ว +4

    This tutorial is truly amazing. It's just opened a new door to me to work with Generics.

  • @mondialelectronics2570
    @mondialelectronics2570 4 ปีที่แล้ว +18

    You are such a necessity for begginer programmers.Keep up the good work!

  • @JoramVanhaerens
    @JoramVanhaerens 3 ปีที่แล้ว +2

    Again you turn something that seems daunting at first into something clear and easy to use! Cheers for the video ;)

  • @subliminalcastillo2126
    @subliminalcastillo2126 3 ปีที่แล้ว +3

    You deserve way more popularity than you have. Especially when youtubers with 2m subscribers cover this exact topic without opening an IDE even once to show an actual hands on example, but instead rely on trying to talk about it alone. Seeing 23k views on this video when there are half-ass 4 minute videos with 1 million views on it makes me sad when they didn't even put 1/10th the amount of example, explanation, and precision you put into your video.

  • @Gino12164
    @Gino12164 4 ปีที่แล้ว +8

    definitely going to use these when I going to make a new tilemap system.

  • @intjengineering
    @intjengineering 3 ปีที่แล้ว +4

    I was looking for a video on "Collections", somehow found this one, and I loved it. You got a +1 sub.
    Keep it up, Mate.
    Greetings from Germany.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      Thanks! I'm glad you found the video helpful!

  • @BimzyDev
    @BimzyDev 3 ปีที่แล้ว +1

    I like how after you present the concept of generics, you follow it with with some use case scenarios. Great video! 😅

  • @MasterofFire-sc3yn
    @MasterofFire-sc3yn 4 ปีที่แล้ว +1

    I waited for this so looooooooooooooong. Thank you!

  • @0fficez0mbie
    @0fficez0mbie 2 ปีที่แล้ว

    Another excellent tutorial - the examples really bring it to life. Thank you!

  • @Hennadii_S
    @Hennadii_S 2 ปีที่แล้ว

    VERY useful and helpful video. I'll certainly add it to my bookmarks and will look at least one more time.

  • @robertotumini395
    @robertotumini395 3 ปีที่แล้ว +1

    Simple and clear, this is how lessons should be! Thanks

  • @jthcoding2441
    @jthcoding2441 4 ปีที่แล้ว +6

    i'm still quite new to coding so i'm super thankful for tutorials like this :)

    • @andeslam7370
      @andeslam7370 3 ปีที่แล้ว +1

      slowly but surely you would realize you have to learn constantly and there isn't really a stage to which you will understand everything...
      i know some java, c++, python, js, you name it.
      yet i when i start coding in c#, i still come here humbly.
      hope you enjoy coding and never give up learning.

  • @arjunbhatt9_7_97
    @arjunbhatt9_7_97 2 ปีที่แล้ว

    Thank you, to create an amazing video.
    It's helped me a lot to understand the c# Lang.

  • @rezs8187
    @rezs8187 7 หลายเดือนก่อน

    Thank you for your absolutely free but full of effort vidoes, I always come back to this channel whenever I want to learn something.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  7 หลายเดือนก่อน

      Thanks! I'm glad the videos have helped you!

  • @parthasarathipatra9483
    @parthasarathipatra9483 2 ปีที่แล้ว +1

    Thanks for the video, learnt a lot of things here.

  • @Oxmond
    @Oxmond 4 ปีที่แล้ว +1

    Awesome tutorial! Generics rocks!!! 👍🤓

  • @mcemgunes
    @mcemgunes ปีที่แล้ว

    Thanks mate! Very clear explaination!

  • @warrior6633
    @warrior6633 4 ปีที่แล้ว

    Such helpful content!!

  • @kopilkaiser8991
    @kopilkaiser8991 11 หลายเดือนก่อน

    Thanks for sharing with your valuable knowledge and thoughts in explaining this topic abour generics. I really wanted to know it better.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  11 หลายเดือนก่อน

      I'm glad you found the vide helpful! Thanks!

  • @imadabab
    @imadabab 4 ปีที่แล้ว +2

    Best Generics Tutorial. Thanks a lot. I have subscribed.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Thanks! I'm glad you found it helpful!

  • @anormalguy8407
    @anormalguy8407 3 ปีที่แล้ว

    Waw just waawww ... you keep blowing me away with these amazing tutorials, i learned so much. thank you!
    Now onto delegates

  • @kopilkaiser8991
    @kopilkaiser8991 ปีที่แล้ว

    Helped a lot ❤️

  • @tamerkhteeb3536
    @tamerkhteeb3536 2 ปีที่แล้ว

    You're simply awesome, Already watched a couple of your videos which I found pretty helpful!!,
    And will be watching a lot more from your channel, So thanks you !!!!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว +1

      I'm glad the videos helped you! Thanks!

  • @adrianrevill7686
    @adrianrevill7686 2 ปีที่แล้ว

    Thanks this cleared up my fuzzy understanding of generics

  • @ayushsidam289
    @ayushsidam289 ปีที่แล้ว

    Thanks for the video sir. 🙂🙌🏻

  • @siyanchen5090
    @siyanchen5090 ปีที่แล้ว

    really well explained!

  • @quentindoret331
    @quentindoret331 3 ปีที่แล้ว +2

    I was struggling understanding the concept of generics, understood it in the first 5min !
    Thanks !

  • @CurtisJensenGames
    @CurtisJensenGames 2 ปีที่แล้ว +1

    Was able to solve my code 4 minutes in. Bless you dude!

  • @adriandiaz4010
    @adriandiaz4010 11 หลายเดือนก่อน

    What a great tutorial!

  • @morrgash
    @morrgash 2 ปีที่แล้ว +1

    What an amazing video, great explanation and editing, subbed and liked :)

  • @amansahu5512
    @amansahu5512 8 หลายเดือนก่อน

    Great Teaching

  • @miriapodel2367
    @miriapodel2367 3 ปีที่แล้ว +1

    This video is EPIC!!

  • @justinwhite2725
    @justinwhite2725 4 ปีที่แล้ว +16

    I learned all of this on my own a few years back and it was a headache. I wish I had something like this then.
    Keep up the great work!
    I really dislike patreon for a lot of reasons, have you considered setting up a subscribestar or another way we can support you?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +5

      I have thought about just having a normal Paypal donate link but I also don't want to have way too many links which might confuse people.
      If you pick up the game bundle from the website you'll be helping out the channel and get some cool games to play!

    • @AG45.
      @AG45. 4 ปีที่แล้ว

      learning such thing is not gonna be even possible to me i'd give up so i respect you

  • @yassinesadik
    @yassinesadik 4 ปีที่แล้ว +2

    yup as you can see we have a nice error xd since when errors are nice, great video as always.

  • @Skyefaux
    @Skyefaux 3 ปีที่แล้ว

    more vids for this playlist please!

  • @raziamansoor4428
    @raziamansoor4428 3 ปีที่แล้ว +2

    This was very helpful Thankyou :)

  • @hasst9261
    @hasst9261 4 ปีที่แล้ว

    Thank you, I like this video

  • @grapy83
    @grapy83 5 หลายเดือนก่อน

    Amazing explanation.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 หลายเดือนก่อน

      I'm glad the video helped! Generics are super poweful!

  • @zekiozdemir420
    @zekiozdemir420 2 ปีที่แล้ว

    Thank you!!!!!

  • @MikoGot
    @MikoGot 4 ปีที่แล้ว

    thank you :)

  • @user-we6si4mi3x
    @user-we6si4mi3x ปีที่แล้ว

    Тhank you very much for the lesson, very clear, helped :)

  • @diadetediotedio6918
    @diadetediotedio6918 4 ปีที่แล้ว +1

    In short, a generic is a type compiled for user-defined types, at compile or execution time, capable of enabling a wide range of operations on the same type, or on types with similar properties. Unlike Java, where they are just abstractions from the runtime, in C #, generics effectively generate code.

  • @lime_68
    @lime_68 ปีที่แล้ว +1

    I miss those fast forwarding(which are quite soothing) stuff in your udemy strategy course 😄

  • @catafest
    @catafest 4 ปีที่แล้ว

    good tutorial ... and then add an EmptyObject ... this is another reason why I like the C# and Unity 3D game engine.

  • @ShhFah
    @ShhFah 4 ปีที่แล้ว

    thx dude

  • @johndev752
    @johndev752 3 ปีที่แล้ว

    Very Nice

  • @7izaak
    @7izaak 3 ปีที่แล้ว +1

    Thanks to you , now i’ve understood the real reason why generics are important and why they are useful

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      If you want to see a practical use case here is my Grid using Generics th-cam.com/video/8jrAWtI8RXg/w-d-xo.html

    • @7izaak
      @7izaak 3 ปีที่แล้ว

      @@CodeMonkeyUnity thank you

  • @robertholl8914
    @robertholl8914 3 ปีที่แล้ว

    .... that was awesome

  • @AG45.
    @AG45. 4 ปีที่แล้ว

    dude u should have 1 million subs

  • @fredflinstoner9530
    @fredflinstoner9530 ปีที่แล้ว

    WOW thanks

  • @davidecheverry0517
    @davidecheverry0517 4 ปีที่แล้ว +1

    Hey! I really enjoy your videos, I would like to learn programming but I really have no Idea where to start, what video would you recommend from your channel for someone n00b as me?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      If you're a complete beginner in Unity watch these videos to get acquainted with the engine th-cam.com/play/PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT.html
      After that try making a complete game like this th-cam.com/video/b5Wpni9KPik/w-d-xo.html

  • @kken8766
    @kken8766 4 ปีที่แล้ว

    great vid~

  • @smy5798
    @smy5798 4 ปีที่แล้ว

    Dude i love your tutorials. Could you make a game from stratch and record it for us.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      I've made this one completely from scratch, it's my longest video! th-cam.com/video/b5Wpni9KPik/w-d-xo.html

  • @Danyanyanyanya
    @Danyanyanyanya 4 ปีที่แล้ว

    You forgot to explain covariance and contravariance in generics. But still very nice video for beginners :)

  • @eshika1336
    @eshika1336 4 ปีที่แล้ว

    actually, I am working on my friends project it on c# and I want to popup a website from that software but we don't know how to change website links from server or database, ​we just need to change website link daily

  • @rickyc1991
    @rickyc1991 3 ปีที่แล้ว

    at 9:22, on line 36, I tried to give T a value of 2, "public T value = 2;" but got a type error. I'm confused by this because on line 19 I already set to . Is there a better way to do this?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +2

      When you make a class a generic you are saying that it will be compatible with just about any type.
      You can use it with an but you can also use it with a
      So you cannot define public T value = 2; because that would not compile if you created an instance of the class using anything other than int.
      If you want specifically to store an int then define public int value; If you want to store the generic type that the class uses then do public T value;

  • @Xenrel
    @Xenrel 3 ปีที่แล้ว

    Why do the action and func delegates have the "in" keyword before the generic type, while your custom delegates seem to work without the "in" keyword?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      The in keyword simply forces those parameters to be inputs, if you don't add it then they can be inputs or outputs.

  • @mikhailhumphries
    @mikhailhumphries 2 หลายเดือนก่อน

    I only watched the first 4 minutes and then I got it. Short tutorials for people in a hurry

  • @DCRdemonLORD
    @DCRdemonLORD หลายเดือนก่อน

    I felt like i gained a lot of knowledge when watching your videos but the next second i forget almost half of it, guess i just have to try them out myself and not just keep watching them again and again 😅

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  หลายเดือนก่อน +2

      That's normal, programming isn't really about memorizing but rather about problem solving, and that's a skill that takes time to really learn. As long as you're actively paying attention then you are learning, even if it doesn't feel like it
      Keep at it!

    • @DCRdemonLORD
      @DCRdemonLORD หลายเดือนก่อน

      Thanks for the motivation bro

  • @popcream2082
    @popcream2082 4 ปีที่แล้ว +2

    Ngl I didn't understand much but good video regardless

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      What part didn't you understand?

    • @popcream2082
      @popcream2082 4 ปีที่แล้ว +1

      @@CodeMonkeyUnity I don't know anything about coding and such and watched this video by mistake. And after reading the comments , seems like many people found it helpful hence good video. Xd

  • @rickyc1991
    @rickyc1991 3 ปีที่แล้ว

    at 6:40, is it possible to have TestMultiGenerics return t1 and t2? what should we use to replace void?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      You want to return 2 values, one of T1 and one of T2?
      If you're using C# 7 you can look into Tuples
      private (T1, T2) TestMultiGenerics(T1 t1, T2 t2);
      Or you can use out parameters
      private void TestMultiGenerics(T1 t1, T2 t2, out T1 t1Result, out T2 t2Result);

    • @rickyc1991
      @rickyc1991 3 ปีที่แล้ว

      @@CodeMonkeyUnity thanks so much for your detailed explanations! I find your videos extremely helpful and have subbed to your channel :)

  • @Caveine
    @Caveine 2 ปีที่แล้ว

    I can tell that you are a kind of person that like to starring directly into the sun.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว +1

      Nope, just someone whose eyes burn for trying to focus on tiny white letters if I use dark mode

    • @Caveine
      @Caveine 2 ปีที่แล้ว

      @@CodeMonkeyUnity XD, you got a point

  • @lukas3065
    @lukas3065 2 ปีที่แล้ว

    5:49 well it makes sens but i got one Question left, why we dont worke withe Objekt's? it seams identicle 4 me

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      Generics enforce the correct type. If you use objects then you can use one type for the first element and a completely different type for the second element which will break everything

  • @empressredbird
    @empressredbird ปีที่แล้ว

    nice

  • @anonymoussloth6687
    @anonymoussloth6687 3 ปีที่แล้ว

    at 7:37, what does the "in T1, in T2 ..." mean?
    also, at 7:49, what does the "out TResult" mean?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว

      That's just the name for the Generic type, usually it starts with a T, so normally you have T1, T2 and if you have outputs normally they are named TResult

    • @anonymoussloth6687
      @anonymoussloth6687 3 ปีที่แล้ว

      @@CodeMonkeyUnity I meant the 'in' word that is before T1 and T2

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      @@anonymoussloth6687 in is an input parameter, out means output

    • @anonymoussloth6687
      @anonymoussloth6687 3 ปีที่แล้ว

      @@CodeMonkeyUnity I see. I am a bit new to C# and unity so was a bit confused. Also, the reason why i asked this is because i noticed that Action and Func used in and out but you didn't. Does that make any difference?

  • @FinitiXgameDepartment
    @FinitiXgameDepartment 4 ปีที่แล้ว

    hi, i need help about music licence for my game background music, i just dont know where to buy. help help help.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Normally I get my music from AudioJungle

    • @FinitiXgameDepartment
      @FinitiXgameDepartment 4 ปีที่แล้ว

      @@CodeMonkeyUnity thanks man. Each song has many license and price, which one is ok?I really can't pay 300 for each song right now😢

  • @kundam12
    @kundam12 2 ปีที่แล้ว

    what if i want to make a function that can create an array and name it for example i pass "hello" 3 int
    it make int hello array length 3

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      int[] hello = new int[3];
      Creates a new int array with 3 elements named 'hello'

    • @kundam12
      @kundam12 2 ปีที่แล้ว

      @@CodeMonkeyUnity yes but i need a function that does this i pass at the function the name the type and the lenght

  • @asphaltbuddies6613
    @asphaltbuddies6613 4 ปีที่แล้ว

    Will be ur student from now.

  • @shubhparmar3504
    @shubhparmar3504 4 ปีที่แล้ว +1

    BRO PLZZZ MAKE A TUTORIAL ON G DEVELOP . ... I JUST AM STARTING TO LEARNING TO CODE SO PLZZ

  • @cosmiccry6675
    @cosmiccry6675 ปีที่แล้ว

    Thx for the vid. But generics are using a lot more memory, right?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว +1

      Compared to what? A class with a hardcoded type? I guess there would be some overhead but it will be miniscule

  • @sabrango
    @sabrango 4 ปีที่แล้ว

    THX!
    Code Monkey Please make some tuts about bake simulation (such as particle) in unity!
    I know that it works with an Array saving time and transform data of the particles but, to avoid crash during billions particle simulation
    how to write code in unity?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      You mean the new particle system? I haven't used it yet but it's definitely on my list!

    • @sabrango
      @sabrango 4 ปีที่แล้ว

      @@CodeMonkeyUnity I mean the way it works! For instance, most studios use Houdini to simulate physically correct particle system and then exports it to any engines !
      Here I want to use Unity to simulate entities with physical system and then use that cache data to work further!!!

  • @random_precision_software
    @random_precision_software 4 ปีที่แล้ว

    I'm looking for a AI chess tutorial.. Is it as big as I world image it would be?

  • @2weirddev676
    @2weirddev676 4 ปีที่แล้ว

    hey can you make a tutorial about perlin noise?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      I have thought about doing some random map generation videos, could be interesting

  • @matteosberna735
    @matteosberna735 2 ปีที่แล้ว

    Is it possible to add a generic class in a list?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว +2

      Sure, if you define MyClass inside it you can make a List or T[]

  • @rjlacanlaled9419
    @rjlacanlaled9419 2 ปีที่แล้ว

    What's the purpose of constraint? Isn't it just better to just explicitly say that instead of type T, you wanna receive a type of IEnemy instead?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      If your constaints are so limited that only a single class is valid then sure at that point you might as well use that class directly. But the goal of generics is to allow your code to work with any number of classes, if that's not what you want then yea don't use generics.

  • @danpeled2522
    @danpeled2522 ปีที่แล้ว

    can't you use the object var instead ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว

      On where? On the T? No, var is a dynamic type that the compiler converts to the inferred type, it's not a type in itself

  • @TinyDeskEngineer
    @TinyDeskEngineer 2 ปีที่แล้ว

    I wanted to figure out how to use generic arrays but now I noticed the delegate keyword at the bottom of the screen for a second so I'm going to google what that does because I have no attention span

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      I made a video on delegates th-cam.com/video/3ZfwqWl-YI0/w-d-xo.html
      Essentially they let you define a function signature so you can store a function in a field or pass it as a parameter.

  • @uchihai_a_h4871
    @uchihai_a_h4871 3 ปีที่แล้ว

    Why don't we just use a interface as function parameter than using generic and then limiting it to an interface?
    I mean interface and generics are kind of similar and I can't think much use cases for generics

  • @katlegosityi59
    @katlegosityi59 ปีที่แล้ว

    2:51

  • @BahawalTV
    @BahawalTV 4 ปีที่แล้ว

    I love the generics but don't know anything about unity!

  • @katlegosityi59
    @katlegosityi59 ปีที่แล้ว

    4:30

  • @katlegosityi59
    @katlegosityi59 ปีที่แล้ว

    6:34

  • @daniilparokonnyy7980
    @daniilparokonnyy7980 4 ปีที่แล้ว

    So, what are the real usages of generics in Game Dev?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Check out the Grid System video to see a very practical example th-cam.com/video/8jrAWtI8RXg/w-d-xo.html

  • @andylockhart257
    @andylockhart257 4 ปีที่แล้ว +1

    How do you do this keyboard sound? 😎

  • @CodingJedi
    @CodingJedi 4 ปีที่แล้ว

    👏👏

  • @mamupelu565
    @mamupelu565 2 ปีที่แล้ว

    internal interface IRepository : IDisposable where TEntity : Entity
    ^^
    didnt understand this....

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      That interface uses a generic type which that type must extend Entity
      For example you could use PlayerRepository : IRepository
      And make sure Player : Entity
      But not sure where you took that code from so check the source code for the specifics on what all those classes do

  • @mognomoinak1309
    @mognomoinak1309 3 ปีที่แล้ว

    From simple to hard in 10min

  • @gaming4fun419
    @gaming4fun419 2 ปีที่แล้ว +2

    While this is one of the best overviews on generics i've seen so far it still feels rushed. Many examples could really need some more time to let the viewer wrap their head around what you are doing and some could use a more practical implementation; like what other than int would you usa in Damage(T t)? An example where T would make sense to use than simply int would be helpful to make it both more understandable and memorable.

  • @AbdurRahman-bg8zu
    @AbdurRahman-bg8zu 4 ปีที่แล้ว

    A very special Thanks from INDIA.....!!!! [ A little help required....!!! ]
    Here is the thing: I request a tutorial for real-time level editor (i.e in-game level editing) for isometric 2d game
    Please make a tutorial on it, so that one can make a game in which they can make levels that uses game prefabs and play & share their creation (levels) {if someone uses the technique.}
    I needed an In-game Isometric type level editor for my game but I'm just a beginner and I don't know how to achieve it.
    It would be great video for others too..!!!!!
    whoever sees this like if you agree...!
    and if (Author)
    {
    please give us the tutorial for it....
    }

  • @tarikkaya3180
    @tarikkaya3180 4 ปีที่แล้ว

    are you interested in vr in unity

  • @excellNexcel
    @excellNexcel 4 ปีที่แล้ว

    I have to keep looking at these videos or else I will simply forget the concepts

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      The more you use them the more they will be stored in your memory, game development and programming is all about experience so keep at it!

    • @england4tommy898
      @england4tommy898 4 ปีที่แล้ว

      @@CodeMonkeyUnity The only problem is that it is a full time job and even so, there are not enough hours in the day...learn, re-learn...on and on

  • @fealllback5539
    @fealllback5539 3 ปีที่แล้ว

    Respect from Russia 🇷🇺🤝🇺🇲

  • @earlninoalajid8105
    @earlninoalajid8105 4 ปีที่แล้ว

    What is the best programming language for game development?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Depends on the engine, Unity only supports C#

  • @markcuello5
    @markcuello5 2 ปีที่แล้ว

    Help me

  • @decodedbunny101
    @decodedbunny101 4 ปีที่แล้ว

    I thought it said genetics

  • @issaelalexanderynumazenten552
    @issaelalexanderynumazenten552 4 ปีที่แล้ว +1

    Too much to my brain.