Generics in C# and Unity – Do More with Less Code



Generics in C# and Unity – Do More with Less Code

Generics in C# and Unity - Do More with Less Code

Generics in C# and Unity help reduce code duplication by reusing the same code for different types. This means less code to write, less code to debug and your project can get finished sooner. We’ll look at generic functions, generic constraints, and generic classes within C sharp.

Written Blog Post on Generics: https://onewheelstudio.com/blog/2020/12/27/c-generics-and-unity

Tutorial Code: https://github.com/onewheelstudio/Adventures-in-C-Sharp/tree/main/Generics

C# Constraints: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters

Thank You!!!
►► Владимир Перепелицын for subscribing! ||||||||||||||| 121% ||||||||||||||| 24.3K/20K
►► Michael Linzenmeyer – Spoke in the Wheel for being the newest channel member!
►► Jeremy Wolf – Spoke in the Wheel for being the newest patron!

Want to support the Channel?
*******************************
Shop the Unity Asset Store (affiliate): https://assetstore.unity.com/top-assets/top-paid?aid=1100lHSw
Become A Channel Member: https://www.youtube.com/channel/UCkr9CPPqT9VWUjkpo3HcACg/join
Or a Patron: https://www.patreon.com/onewheelstudio
Grab a T-Shirt: https://onewheelstudio.com/merch/
My video and streaming kit: https://kit.co/onewheelstudio/tutorial-video-production
Buy a Game Design Books: https://kit.co/onewheelstudio/game-design-reading-list-unity-c-blender-and-more

Other Links
************
Discord: http://discord.onewheelstudio.com
Twitter: https://twitter.com/OneWheelStudio
Devlog: https://onewheelstudio.com/
Twitch: https://go.twitch.tv/onewheelstudio

Timestamps
*************
0:00 Generics Intro
2:09 Custom Generic Function
5:26 Calling Generic Functions
5:53 Generic Constraints
6:46 Destroy Objects of Type
7:32 Object Type Under Mouse
8:26 Multiple Arguments
9:18 Multiple Constraints
9:39 Generic Classes
10:46 Generic Object Pooling
11:42 Generics vs. Inheritance

#CSharp #BetterCode #GameDevelopment #Unity #generics #unitygenerics

Comments are closed.