C# Extension Methods

  Рет қаралды 23,887

Tarodev

Tarodev

Күн бұрын

Пікірлер: 148
@Tharky
@Tharky 3 жыл бұрын
✔ Very very cool ✔ Very easy ✔ Very neat
@SpicyMelonYT
@SpicyMelonYT 3 жыл бұрын
Every single interesting thing that I have heard about recently you make a video on like a week later. You are literally predicting what I want to learn next. Legend!
@Tarodev
@Tarodev 3 жыл бұрын
I'm just outside your window
@SpicyMelonYT
@SpicyMelonYT 3 жыл бұрын
@@Tarodev There actually was a person outside my window a few hours before I wrote that. And it wasn't my neighbors cause they are always loud and talking when they go by. Creepy bro! lol
@DmpDk
@DmpDk 3 жыл бұрын
@@SpicyMelonYT Ah no worries, it's normal too see programmers foraging outside in ya garden around this time of year, just give him a cuppa of joe and he will bugger of on his own. else, sprinkle your garden with invitations to sprint meetings and mails from projectmanagers / IdeaGuys with "the next big thing" to keep your garden guaranteed programmer free
@SpicyMelonYT
@SpicyMelonYT 3 жыл бұрын
@@DmpDk LMAO will do mate!
@UnofficialCyane
@UnofficialCyane 6 күн бұрын
I've been writing C# code for years, but sitting here watching your video makes me feel like I'm in class on my first day at _Hogwarts._ Thank you for putting out these videos, they're extremely helpful
@Tarodev
@Tarodev 6 күн бұрын
Hah 😅 Glad they could help you!
@ershadhussain8196
@ershadhussain8196 3 жыл бұрын
you are slowly becoming my favorite game dev tutorial channel. keep up the useful content!
@azavier-a
@azavier-a 3 жыл бұрын
hes been mine since the video about generics
@Tarodev
@Tarodev 3 жыл бұрын
I appreciate it :) Hopefully I can climb to #1 of your list... It is now my mission!
@Tarodev
@Tarodev 3 жыл бұрын
Thanks a bunch man :) Glad I can deliver enjoyable content for you
@Tarnil97
@Tarnil97 3 жыл бұрын
One thing I'd add is that you can use the 'ref' keyword on the extended argument. Can be useful for, for example, mutating a collection in place
@restushlogic5794
@restushlogic5794 3 жыл бұрын
We need kind of tutorial of ref I think.
@hamsterbyte
@hamsterbyte Жыл бұрын
This was a rollercoaster of me shaking my head and nodding. Makes a static class called extensions, adds a method to it and calls if from the class. *face palm* Immediately turns the method into a proper extension method. Redeemed. Makes an extension method to return a random from a list of strings. *face palm* Immediately makes the method generic. Redeemed. You're a true legend.
@Tarodev
@Tarodev Жыл бұрын
Gotta keep you guessing my man
@kubstoff1418
@kubstoff1418 3 жыл бұрын
I'm amazed by the simplicity to usefulness ratio!
@ZacIRL
@ZacIRL 3 жыл бұрын
You are actually someone who knows what he is talking about! Thanks!
@JesusW4y
@JesusW4y Жыл бұрын
Absolute favorite channel for intermediate level programming!
@rafarodriguez4765
@rafarodriguez4765 2 жыл бұрын
After 4 years of using C# I learn something useful in each video. Thanks
@09mrbubbles
@09mrbubbles 2 жыл бұрын
Was about to skip this since I thought I already knew what extension methods were. Turns out I did not. It's absurd how much a ten minute video can help you in your career. Thanks a bunch!
@ewwitsantonio
@ewwitsantonio 3 жыл бұрын
Man, I love this channel. You are creating content right in my level of skill. I can follow everything easily, but you keep on showing me things that are new/useful. Thanks for the vid!
@ivo435
@ivo435 2 жыл бұрын
I am still pretty new to game development (I've been doing it for about 9 months now). This channel is absolute gold. I can't tell you how many times I have thought to myself "I wish this was a method I can call". For me, the hardest part is keeping things nice and tidy (I tend to make waaay to many scripts and I start getting lost in them). This is definitely a neat trick and I will 100% use it in the future. Thank you!
@vayctorkeesh5393
@vayctorkeesh5393 2 жыл бұрын
ty for putting those screenshots of extension methods at the end, really neat !
@fleity
@fleity 3 жыл бұрын
I noticed it in this video and a bunch of other video of you as well. Your Unity compiles and enters playmode ridiculously fast. For playmode enter I know you can disable scene and domain reload but I have run into problems with that once before. I would love a video on how to improve the speed of entering playmode (and writing your scripts in a way that works with skipping domain reload) and improving compilation speed to the level it works for you (I am already using asmdefs but even in a project with only a single script it is not as fast as yours). Thanks a bunch for the good content :).
@Tarodev
@Tarodev 3 жыл бұрын
This would be a few things: 1. This is a fresh project, so not many scripts 2. I edit a bit of the load out so you don't have to wait for it ;)
@fleity
@fleity 3 жыл бұрын
@@Tarodev hehehe well okay that obviously works too :D
@datablob
@datablob 3 жыл бұрын
@@fleity the hollywood style of development :D
@somethingdarkinside
@somethingdarkinside 3 жыл бұрын
@@Tarodev big brain 🧠
@dabekka
@dabekka 2 жыл бұрын
your channel is a goldmine for game programmers!
@yusufhabib3507
@yusufhabib3507 Жыл бұрын
you are my fav game dev channel plz keep making vids like this
@kyleme9697
@kyleme9697 Жыл бұрын
Time to rewrite all my code again !! That generics thing was really interesting, I need to look into that some more.
@Lukfin
@Lukfin 3 жыл бұрын
Very nice! I hope to build my toolbox of useful extension methods. Thanks for the video! Gave it a big like.
@bunggo9914
@bunggo9914 3 жыл бұрын
I always learn an entirely new thing about C# in this channel
@Димас-ТвойРазработчикИгр
@Димас-ТвойРазработчикИгр 3 жыл бұрын
Thank you very much, your tutors are wonderful
@datablob
@datablob 3 жыл бұрын
Awesome stuff, Taro. I laughed so hard during the checklist of coolness and neatness, well done! :D
@datablob
@datablob 3 жыл бұрын
I particularly also liked how you dove into multiple practical demos of the concept!
@meuix3218
@meuix3218 3 жыл бұрын
bro this is INSANE !!!!!!!!!!!!!!!!!!!!!!!!!!!!
@narkid89
@narkid89 3 жыл бұрын
As always, good stuff!
@jsn4591
@jsn4591 3 жыл бұрын
Back again after an excursion through your channel. Awesome stuff, you're a great teacher! I hope you keep on going with more intermediate & advanced topics for us peeps who are beyond the basics. One thing I notice you do is use var instead of specifying the type when defining references, is that just a personal taste thing?
@Tarodev
@Tarodev 3 жыл бұрын
Personal taste, but efficiency comes into it. I can tell the type by the declaration and if I can't I'd prefer to hover to see than have every type on display. Sometimes you don't know the type right away, so I'd prefer to just start coding than sit there thinking about it. Curious why you prefer specifically typed?
@jsn4591
@jsn4591 3 жыл бұрын
@@Tarodev thanks for your insight. I wouldn't say I prefer specifically typed, I just learned it that way. Its always seemed unnecessary to me to write the Type twice though, so the var approach is quite appealing.
@Tarodev
@Tarodev 3 жыл бұрын
@@jsn4591 it's the time to change! Start doing it and you will kick yourself for not doing it sooner.
@JoschinoDev
@JoschinoDev 3 жыл бұрын
*this* is incredible. Time to rewrite my helper class
@tudorelRo
@tudorelRo 3 жыл бұрын
Awesome video as always! Just a small thing at min 6:50 you said that you are mutating a string, but that's false, you are returning a new string and printing it, the "hero" string remains the same . ("String objects are immutable: they cannot be changed after they have been created. All of the String methods and C# operators that appear to modify a string actually return the results in a new string object")
@Tarodev
@Tarodev 3 жыл бұрын
I talk about string immutability in my previous video. I more meant to the context of the caller, we are 'mutating' the string. Not from a programmatic standpoint but a functional standpoint. It's good you mentioned it anyway as others may have the wrong idea 💡
@PepijnLinden
@PepijnLinden 3 жыл бұрын
While watching this video I thought to myself: "This is neat! I should really subscribe to this guy!" But apparently I was already subscribed because of that amazing DOTWEEN video. Big thanks for spreading your knowledge and keep up the great content!
@Mariofan7
@Mariofan7 2 жыл бұрын
Thanks a lot for the video. Extension methods indeed seem Very very cool, very easy and very neat
@mirtanvirahmed3868
@mirtanvirahmed3868 3 жыл бұрын
I would love to see you as the game dev KZbin channel 💜 you are just awesome 🤪
@DJnoratos
@DJnoratos 3 жыл бұрын
Really cool indeed ! I code in C# for 3 years now and did not know about this
@Tarodev
@Tarodev 3 жыл бұрын
Programming is such a vast topic with so many concepts. You'll always discover new goodies 😊
@fratyldrm1749
@fratyldrm1749 3 жыл бұрын
My new favorite channel
3 жыл бұрын
Love your videos, thanks for sharing!
@Etredal
@Etredal 3 жыл бұрын
Wow I'm going to use this more!
@mementomori7160
@mementomori7160 3 жыл бұрын
I had no idea about this, it'll be very usefull
@eduardopoffo9764
@eduardopoffo9764 3 жыл бұрын
Wonderful tutorial, had no idea this existed and now I may never stop using that hahaha +1 sub
@jsn4591
@jsn4591 3 жыл бұрын
Great video! To the point and a clear bunch of examples. Thanks for adding something new to my toolbox. Subbed and looking forward to checking out your other vids.
@pliniomourao
@pliniomourao 3 жыл бұрын
Nice, simple and easy. Thank you for this.
@lukastomasek8038
@lukastomasek8038 3 жыл бұрын
Great Tutorial as always!
@monishdhayalan2552
@monishdhayalan2552 3 жыл бұрын
i have notifications on for this channel but still no notification, i only look at it when it comes in my recommendation
@Tarodev
@Tarodev 3 жыл бұрын
A few people have said this 😢
@ardaozler631
@ardaozler631 3 жыл бұрын
Amazing tutorial as usual but can you zoom a bit when using rider so mobile users can see easier thank you ❤️
@Tarodev
@Tarodev 3 жыл бұрын
Ah dude in editing I remembered I didn't zoom in and felt bad. I tried to add zoom on every code segment but it looked horrible. Sorry bud >
@libberator5891
@libberator5891 3 жыл бұрын
this. this is excellent And so are you, my dude
@null21235
@null21235 3 жыл бұрын
That's so perfect for tutorial, thanks
@TheKr0ckeR
@TheKr0ckeR 3 жыл бұрын
great guide, thanks
@88dejw
@88dejw 3 жыл бұрын
Great explanation! Could you please make the font a little bigger in the editor next time recording? It's a little hard to see watching this on phone
@Tarodev
@Tarodev 3 жыл бұрын
Yeah sorry about that. I realize I didn't zoom when I started editing. I tried zooming the video but it looked bad 😢
@notagamedev5494
@notagamedev5494 3 жыл бұрын
Thank you!
@JimPlaysGames
@JimPlaysGames 3 жыл бұрын
This is so incredibly useful.
@svendpai
@svendpai 3 жыл бұрын
Another great video :) still waiting patiently for the knitting one
@Tarodev
@Tarodev 3 жыл бұрын
Can you handle my knitting? Not so sure
@svendpai
@svendpai 3 жыл бұрын
Only if you can knit my handle
@leonidus101
@leonidus101 2 жыл бұрын
interesting hero gradation :D so humble that Tarodev
@michalski9141
@michalski9141 3 жыл бұрын
I’ve always wanted to know how to make those, great tutorial thank you
@chawlahimanshu6219
@chawlahimanshu6219 3 жыл бұрын
I did the random one before, but used IEnumerator instead of IList to make it available for other data types as well
@Tarodev
@Tarodev 3 жыл бұрын
A bit more difficult with IEnumerable as it doesn't offer count. But still doable
@larryd9577
@larryd9577 3 жыл бұрын
Extension Methods are just syntactic sugar for grouping util functions to their according classes. Which is stupidly useful. Kotlin does it the exactly the same way, JavaScript and TypeScript has it too, just works a little different. I'd usually create separate classes for the extension methods named according to the class which I extend on. Like the List extensions go into ListExtensions and the Hero extensions in HeroExtensions and have them all in a name space for alle extension methods.
@Tarodev
@Tarodev 3 жыл бұрын
I'm glad you don't throw every single method in a monolithic class! I was having a convo recently about where people store enums. Some people would chuck all enums in 1 "enums" file. I personally put them below their main class declaration. enum HeroType will be below the ScriptableHero declaration for example.
@FacePalmProduxtnsFPP
@FacePalmProduxtnsFPP Жыл бұрын
Super cool! Thanks man
@vishalkhombare
@vishalkhombare 3 жыл бұрын
Tarodev You are such a master!! ..What books you read? recommend to us beginners and intermediates ? Which online resource can teach us all this C# stuff like you do ? Can you recommend somethings / many things additional who really want to get good at this C# programming art. Some day please take time and make a video on this "Recommeded learning resources as per Tarodev". Thanks.
@Tarodev
@Tarodev 3 жыл бұрын
I didn't read any books. I learned by jumping in to make things and just looking stuff up as I got stuck. I would suggest not learning purely via unity tutorials, but focus more on pure c# content. Everybody learns differently, I always found hands on the best for me, but books may be best for you 😊 as long as you find the method you choose to be fun and not boring I'd say you're doing it right.
@vishalkhombare
@vishalkhombare 3 жыл бұрын
@@Tarodev Yes Agreed Boss. Everyone's in that sense. Thanks a lot for your kind reply.
@AlexBlackfrost
@AlexBlackfrost 3 жыл бұрын
Wow, this is great
@jean-michel.houbre
@jean-michel.houbre 3 жыл бұрын
Very clear.
@adamsen2
@adamsen2 3 жыл бұрын
Hey thank you for your great videos. I would like to suggest a video about using events in unity, how to set them up and subscribe to them in another script. Best regards
@chujies
@chujies 3 жыл бұрын
Very very cool Very Easy Very Neat! Haha love it
@askcookie1
@askcookie1 3 жыл бұрын
I'd love to see a video about custom attributes. Commands from Quantum Console are good example [Command] public void Teleport(Vector3 pos) This would automatically grab name of method and register this as command with Vector3 argument.
@Tarodev
@Tarodev 3 жыл бұрын
Didn't know Quantum Console existed until just now, pretty nice!
@therupoe
@therupoe 3 жыл бұрын
Hey Tarodev! Love the channel, thanks for all of the useful info. At the moment I'm learning c# and am just now getting into (maybe) intermediate topics (inheritance, polymorphism, structs and interfaces). At what point am I going to know enough to be effective in unity? I'm worried ill jump in too early, brute force stuff and learn the wrong habits. Is there like a minimum level of competency or something? I mostly understand your videos and if nothing else they give me new terms and concepts to research when I'm in over my head.
@Tarodev
@Tarodev 3 жыл бұрын
Interesting question. I would say learn some basic design patterns like the enum-state manager in my GameManager video and then also a normal state manager (infallible code has a good one). If you're making a smallish game, stick with the enum game manager in my opinion. With that knowledge I think you're good to just jump in. Making mistakes is learning. You can always join my discord to ask me/community questions if you're unsure about something
@therupoe
@therupoe 3 жыл бұрын
@@Tarodev thanks, man! I appreciate you taking the time.
@Structed
@Structed 3 жыл бұрын
You should create a library with your extension methods!
@Tarodev
@Tarodev 3 жыл бұрын
I've seen a few repos around with a bunch, but yeah you're right there certainly a need for an easy to install package.
@supendi42
@supendi42 3 жыл бұрын
Of course Tarodev is inside heroes list
@Tarodev
@Tarodev 3 жыл бұрын
Yeah boi 😉
@alaslipknot
@alaslipknot 3 жыл бұрын
✅ Very Very Cool ✅ Very Easy ✅ Very Neat
@benjaminlehmann
@benjaminlehmann 3 жыл бұрын
Good job
@NOOB097
@NOOB097 3 жыл бұрын
Super cool 😎
@homemacai
@homemacai 3 жыл бұрын
it's 420 O' Clock in classroom 69 kids!
@TheKr0ckeR
@TheKr0ckeR 3 жыл бұрын
I would be really glad a tutorial on "ref" "out" keywords
@bsdrago
@bsdrago 3 жыл бұрын
Something could be good is a video about namespaces. I take some 3rd parties scripts and almost no one uses. So, how to use and about how struct them in directories could be a good video =) (Sorry about my english)
@tinyctr7433
@tinyctr7433 3 жыл бұрын
实在是太有用了!我怎么没有更早认识你呢!
@EternalStud3nt
@EternalStud3nt 3 жыл бұрын
I just found out your channel... All I have to say: This is a goldmine!
@dennisgonzales9521
@dennisgonzales9521 2 жыл бұрын
Thanks!!!
@VEOdev
@VEOdev 3 жыл бұрын
I have a question .. sometimes when I work with static classes in some mobile devices they doesn't work for some reason .. some said they get garbage collected , is there a way to protect a class from getting garbage collected or is there something I don't know about ?
@RayHorn5128088056
@RayHorn5128088056 2 жыл бұрын
This is a very old (I mean ancient) OOP trick but thanks for sharing. 😇
@bambuccigames
@bambuccigames 3 жыл бұрын
How come you enter Play Mode so fast?
@ardaozler631
@ardaozler631 3 жыл бұрын
He has a tutorial on that
@Tarodev
@Tarodev 3 жыл бұрын
Here it is: kzbin.info/www/bejne/hmjGiomdast0rLs Also, ctrl + p is the hotkey to enter
@mirtzata
@mirtzata 3 жыл бұрын
What code editor are you using VS Code?
@lewaplay
@lewaplay 3 жыл бұрын
Nice
@AetherXIV
@AetherXIV 3 жыл бұрын
NICE
@ericbeaulieu419
@ericbeaulieu419 3 жыл бұрын
Unity knows that Thanos isn't a hero
@Tarodev
@Tarodev 3 жыл бұрын
It seemed that way... We know he is though
@SFotakos
@SFotakos 2 жыл бұрын
Great video. A little concerned about what's considered a hero though. *stares at Thanos' name
@Rovsau
@Rovsau 2 жыл бұрын
Hercules, Thanos, Tarodev I can see it now... public static override ThanosSnap() => DoNothing(); Tarodev saves the world \o/
@Tarodev
@Tarodev 2 жыл бұрын
The power of a programmer
@plixo4712
@plixo4712 3 жыл бұрын
whats with the rider licences?
@WarlikeCracker
@WarlikeCracker 3 жыл бұрын
Спасибо за годный контент
@Tarodev
@Tarodev 3 жыл бұрын
You're welcome :)
@bini7203
@bini7203 3 жыл бұрын
420 69 lol This legend sneaked in these holy numbers in a programming tutorial. Niceee XD
@Tarodev
@Tarodev 3 жыл бұрын
Excuse me they were entirely random
@rutchjohnson
@rutchjohnson Жыл бұрын
Gold
@znimator
@znimator 3 жыл бұрын
Why his Unity loading so fast i cant understand bruh my takes like 20 seconds to load stuff and then run game
@Tarodev
@Tarodev 3 жыл бұрын
Check out this tutorial my guy kzbin.info/www/bejne/hmjGiomdast0rLs
@youcancallmedoggie
@youcancallmedoggie 3 жыл бұрын
ENGAGING
@Tarodev
@Tarodev 3 жыл бұрын
ENGAGING CONTENT?
@youcancallmedoggie
@youcancallmedoggie 3 жыл бұрын
@@Tarodev ENGAGEEEEDD
@Tarodev
@Tarodev 3 жыл бұрын
@@youcancallmedoggie you did well
@YOSFP
@YOSFP 3 жыл бұрын
how does your project start so fast lol
@Tarodev
@Tarodev 3 жыл бұрын
Go to my channel and look for 'enter play mode faster'
@YOSFP
@YOSFP 3 жыл бұрын
@@Tarodev I had a feeling you had one video about that, thanks :)
@TheElvinGamer
@TheElvinGamer 3 жыл бұрын
I am a C# dev but I clicked purely because of the Clash of Clans font so take that for what you will
@Tarodev
@Tarodev 3 жыл бұрын
I love it 😅
@SibghatullahBaloch-k4i
@SibghatullahBaloch-k4i 15 күн бұрын
wooh
@ekekw930
@ekekw930 Жыл бұрын
5:38 lmao
@hryhoriinevmerzhytskyi4299
@hryhoriinevmerzhytskyi4299 Жыл бұрын
Random int 420 😂 Ok, like ✊
@didntask2438
@didntask2438 3 жыл бұрын
Hello
@Tarodev
@Tarodev 3 жыл бұрын
Oh, hi
@somethingdarkinside
@somethingdarkinside 3 жыл бұрын
Good video, really helpful. But unfortunately have to dislike and report because typing braces in the same line is war crime.
@Tarodev
@Tarodev 3 жыл бұрын
Haha getouttahereeeeee
@ГеймДеб
@ГеймДеб 3 жыл бұрын
666th like
@Tarodev
@Tarodev 3 жыл бұрын
🤘
@Sticks_Dev
@Sticks_Dev Жыл бұрын
Old video, but why do you have a flat extension method? Vector3.ProjectOnPlane() already does exactly what that does if you use Vector3.up as the second argument. To be fair, I do wish project on plane were an extension method by default.
@AndrewNostromo
@AndrewNostromo 2 жыл бұрын
public static void DestroyChildrenRecursive(this Transform transform) { foreach (Transform t in transform) { t.DestroyChildrenRecursive(); } Object.Destroy(transform.gameObject); }
@alphanineone
@alphanineone Жыл бұрын
I Made tihs one => public static T GetRandom(this List ts, int initialInclusive = 0, int finalExclusive = 0) { if (finalExclusive == 0) { finalExclusive = ts.Count; } return ts[UnityEngine.Random.Range(initialInclusive, finalExclusive)]; }
C# Events & Delegates
17:21
Tarodev
Рет қаралды 93 М.
The weirdest way to loop in C# is also the fastest
12:55
Nick Chapsas
Рет қаралды 256 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
How To Create Extension Methods in C#
28:58
IAmTimCorey
Рет қаралды 53 М.
Unity Code Optimization - Do you know them all?
15:49
Tarodev
Рет қаралды 204 М.
One LINQ Extension Method You NEED To Know For Cleaner EF Core Queries
11:08
Extension Methods for Structs
16:40
Coding Tutorials
Рет қаралды 1,1 М.
How IEnumerable can kill your performance in C#
11:02
Nick Chapsas
Рет қаралды 121 М.
Easy and Powerful Extension Methods | Unity C#
12:21
git-amend
Рет қаралды 9 М.
10 Things You NEED to Be Doing in Unity
11:40
Tarodev
Рет қаралды 139 М.
C# Extension Methods Tutorial - Extend your C# Knowledge
6:18
tutorialsEU - C#
Рет қаралды 10 М.
C# objects 🧍‍♂️
5:01
Bro Code
Рет қаралды 56 М.