What are Loops? (C# Basics, for, while, do)

  Рет қаралды 28,850

Code Monkey

4 жыл бұрын

🌍 FREE C# Beginner Complete Course! kzfaq.info/get/bejne/priVhZmLntivXaM.html
🔴 Watch my Complete FREE Game Dev Course! 🌍 kzfaq.info/get/bejne/d9N3hqh5nLfHdJs.html
📝 C# Basics to Advanced Playlist kzfaq.info/sun/PLzDRvYVwl53t2GGC4rV_AmH7vSvSqjVmz
🌍 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
✅ Let's learn all about Loops in C#, they are an integral part of programming that you'll use all the time.
For, While, Foreach and Do While.
Learn Unity in 17 MINUTES!
kzfaq.info/get/bejne/e5xxZ7qn2KrJfHk.html
Learn C# BASICS in 10 MINUTES!
kzfaq.info/get/bejne/f6yRrLSa1K2bYXU.html
What are Events? (C# Basics)
kzfaq.info/get/bejne/hduKpcuq0LzdpJs.html
What are Delegates? (C# Basics, Lambda, Action, Func)
kzfaq.info/get/bejne/acCWqtSI0ZO9eWQ.html
What are Interfaces? (C# Basics)
kzfaq.info/get/bejne/g8B_paqJ0Jq8dn0.html
What are Generics? (C# Basics)
kzfaq.info/get/bejne/bbycrM5-2Nm-qp8.html
What are Loops? (C# Basics, for, while, do)
kzfaq.info/get/bejne/Z9yfddhysZu-g6c.html
Unity Tips in 10 MINUTES!
kzfaq.info/get/bejne/i6qhqsdht9msemg.html
Unity Basics for Beginners
kzfaq.info/get/bejne/e5xxZ7qn2KrJfHk.html&list=PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials kzfaq.info/love/FK6NCbuCIVzA6Yj1G_ZqCg
See you next time!
📍 Support on Patreon www.patreon.com/unitycodemonkey
🤖 Join the Community Discord discord.gg/eHjUVrm
📦 Grab the Game Bundle at unitycodemonkey.com/gameBundle.php
📝 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/

Пікірлер: 69
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
🌍 FREE C# Beginner Complete Course! kzfaq.info/get/bejne/priVhZmLntivXaM.html 🔴 Watch my Complete FREE Game Dev Course! 🌍 kzfaq.info/get/bejne/d9N3hqh5nLfHdJs.html 📝 C# Basics to Advanced Playlist kzfaq.info/sun/PLzDRvYVwl53t2GGC4rV_AmH7vSvSqjVmz 🌐 Have you found the videos Helpful and Valuable? ❤️ Get my Courses @t or my Steam Games 🎮 @t Here's another C# Basics video, this time covering on the most important things to know as a programmer, Loops!
@alexw9309
@alexw9309 4 жыл бұрын
Dont use for (int i = 0; i < array.lenght; i++) Better use for (int i = 0, int max=array.lenght; i < max; i++) In the 1. the lenght will be calculated on every loop, on the 2. only once. If u have big loops this could make a speed difference.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup, if performance is a concern then caching the length is a nice an easy way to get some ms
@GymCritical
@GymCritical 4 жыл бұрын
This is definitely good for my inventory script which is taking up approx. 0.27ms rn. Scalability wise, this’ll help.
@nemesis8508
@nemesis8508 4 жыл бұрын
Commenting to remember this later
@anormalguy8407
@anormalguy8407 3 жыл бұрын
thanks, this is going into my collection of performant code :D
@nexgen.graphics
@nexgen.graphics 2 жыл бұрын
Makes sense. Thanks for this.!
@mephistonight2958
@mephistonight2958 4 жыл бұрын
You're very quickly become the best Unity channel on KZfaq, you know? No fuss, no messing about... straight in to it covering the important information in a digestible way. Nice one.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Thanks!
@JTAGames
@JTAGames 4 жыл бұрын
This helps tremendously with the project I’m working on right now, thanks!
@JG-bb4dc
@JG-bb4dc 4 жыл бұрын
Thank you Code Monkey. Really appreciate you making this video on the basic C# loops. Looking forward to your next tutorial like this on C#. Keep making these awesome videos on Coding C# with Unity!!!
@michaelesch
@michaelesch Жыл бұрын
Thank you so much! I've been struggling with the concept of loops and I think it is starting to click.
@dhee9040
@dhee9040 8 ай бұрын
Best vedio on c# loops I've seen everrr
@jackbamford9749
@jackbamford9749 4 жыл бұрын
We need more videos on this series🙌
@ayushsidam289
@ayushsidam289 Жыл бұрын
Finally completed all videos in this playlist 🎉. Thanks for this invaluable playlist sir. 🙌🏻 But please can you make a video on switch statements. 🙏🏻😇
@ThePostalGril
@ThePostalGril 4 жыл бұрын
i like your teaching style. i'm learning c# :) i want to make little games. not for profit tho i know someone like me could never make good games but i wanna do it for fun :)
@svetavasilieva7841
@svetavasilieva7841 4 жыл бұрын
Thank you
@GaiaTree
@GaiaTree 4 жыл бұрын
Hi dude. Can u make trade system for mmorpg games? Thanks for helps.
@supertenchoo4271
@supertenchoo4271 4 жыл бұрын
my brain is boost with loop...make this basic tutorial it real help us who are new in programming
@Andrew90046zero
@Andrew90046zero 4 жыл бұрын
I personally have never used the continue keyword, but I bet there are some places where I could use it. Also, for anyone else reading. I have heard for loops being called "count controlled loops" in case you hear that term. The idea is that while loops are more used for things you are not incrementing repeatedly. And have no solid predefined amount of iterations. So a while loop would be used to hold a simple console program open. Whereas for loops are more for iterating over data structures with a finite size, and therefore, have a known amount of total loops.
@makinamieclair3769
@makinamieclair3769 4 жыл бұрын
you can scan list in reverse order to remove element
@RawHunterX
@RawHunterX 4 жыл бұрын
Great vid. Can you do Events in the future?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
I have covered Events here kzfaq.info/get/bejne/hduKpcuq0LzdpJs.html
@ArunKumar-xg4st
@ArunKumar-xg4st 4 жыл бұрын
Thank you Code Monkey🙂🙂
@iUmerFarooq
@iUmerFarooq 4 жыл бұрын
I'm waiting for next video please upload as quickly as possible?
@manicmillennial3287
@manicmillennial3287 4 жыл бұрын
hey CM, ty for this video! What is the "c" after "char" @ 8:27 and what do you mean? I have some trouble hearing you and understanding what you mean by defining "char"
@Andrelas11
@Andrelas11 4 жыл бұрын
The "c" is just a typical name assigned to character variables. You could have named it whatever you wanted. So "c" is the variable name, "char" is the variable type. The variable has no value on its own until you start passing in values from the Array with the foreach loop.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup it's just the variable name, since it's a "char" I just used "c" but it can be any name you want. char is a C# type that represents a character. A string is composed of characters.
@anormalguy8407
@anormalguy8407 3 жыл бұрын
I already know how to use these in java but watched anyways and found out that certain syntaxes are different so I guess I still learned some stuff :D
@anormalguy8407
@anormalguy8407 3 жыл бұрын
also very nice tip on how to remove an object in a list
@alexw9309
@alexw9309 4 жыл бұрын
Does break 2; work in c# for breaking 2 levels or even more? Im from the php world and we have this syntax there. :-)
@sagiziv927
@sagiziv927 4 жыл бұрын
no, unfortunately you can only break the loop you are in, not the outer loops
@alexw9309
@alexw9309 4 жыл бұрын
@@sagiziv927 ok, thx for the answer :-)
@angelmerchev8933
@angelmerchev8933 4 жыл бұрын
im new at programming im using visual studio and unity looks so alike
@sagiziv927
@sagiziv927 4 жыл бұрын
Important to note that in the for loop you are not forced to write all 3 blocks, you can skip some of them if needed
@Andrelas11
@Andrelas11 4 жыл бұрын
What would be some helpful "game specific" instances you would use each of these loops. I find building on these simple instructions with a practical example helps solidify the information. Many things make sense as a "concept" but implementing the concept is sometimes the most difficult part. Thanks!
@andrewshandle
@andrewshandle 4 жыл бұрын
Looping through a player's inventory, looping through enemies and checking if they are alive (the example CM gives for "Contunue"), looping through visible targets, doing an initiative order in a Turn Based game, updating a status flag on a group of items that are on the ground that is on fire, every system in ECS/DOTS with an Entities.ForEach, etc. Basically, any time there can be more than one of something. FWIW, whenever CM does these types of pure C# mechanical videos, another one follows it which uses what he is talking about, so I imagine his next video will contain loops.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yeah I normally try to do that but this is such a basic concept I couldn't really come up with a simple example to explain it. Every example I thought about would take longer to explain the example than to show the loops in action.
@ighby9828
@ighby9828 4 жыл бұрын
I just get an ad of one of your videos... in your video xd
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Really? Interesting...
@papadross
@papadross 3 жыл бұрын
I'm new to programming and I'm not sure how to ask but I have some code in a for loop that I don't fully grasp. for (int i = 0; i < numArray.Length; i++) { if(Convert.ToInt32(numArray[i])-i != firstArray) { cons = false; break; } } I get what most of this is doing except for the -i behind (numArray[i]). Any info would be most appreciated.
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
I have no idea what numArray and firstArray are meant to represent so I can only tell you what the code is doing Convert.ToInt32(numArray[i]) is converting whatever is in numArray[i] into an integer Then it's subtracting by 'i' which means it's subtracting more and more and the for loop cycles more and more
@papadross
@papadross 3 жыл бұрын
@@CodeMonkeyUnity That's what I was wondering. Thanks.
@user-yg9rq6xn3o
@user-yg9rq6xn3o 3 жыл бұрын
you mean It not runs second time* (not "second loop") at all ? 0_o 13:36
@David-vz4yk
@David-vz4yk 4 жыл бұрын
Could you do tutorials for top down shooter game?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
I've done quite a lot of them and you can see some that I used in the Top Down Shooter game I made unitycodemonkey.com/game.php?g=topdownshooter
@David-vz4yk
@David-vz4yk 4 жыл бұрын
Code Monkey thanks!
@Deadwindshadow
@Deadwindshadow 3 жыл бұрын
Whats the difference between while and if statement? while (i < 3) { do this } if (i < 3) { do this } I don't see a difference here :/
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
The if code block will only run once and the while code block will run for as long as i is under 3
@Deadwindshadow
@Deadwindshadow 3 жыл бұрын
@@CodeMonkeyUnity Ah, sure! I was thinking of an if statement in the update function haha, but isee how useful while could be used in not update! Thank you!!
@brockormond4131
@brockormond4131 4 жыл бұрын
Wow, I didn't even know 'continue' was a thing. Embarrassing. I could explain a Recursive loop, but didn't know continue... that's a college education for ya. Really, you should do a class for Udemy or something... that'd probably sell well.
@BigJTT
@BigJTT 2 жыл бұрын
It's actually painful you don't use the dark theme xD
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Sorry but dark theme is painful for me, I can't look at it for more than 30 seconds
@BigJTT
@BigJTT 2 жыл бұрын
@@CodeMonkeyUnity I feel you probably get that comment alot :D
@mr-spoon
@mr-spoon 4 жыл бұрын
Make video about making amionation
@spe.z.artist
@spe.z.artist 4 жыл бұрын
dai craft make me a sandwich
@mr-spoon
@mr-spoon 4 жыл бұрын
@@spe.z.artist what about tea? Are you writing that while sleeping
@spe.z.artist
@spe.z.artist 4 жыл бұрын
dai craft haha tea would be nice. just thought your comment is a bit demanding. I figured I’d give you a taste of your own medicine. Imagine you work hard to make a video andyou post it and the first comment is “do something else” not even a mention of this video.
@dasmaffin1633
@dasmaffin1633 4 жыл бұрын
Well if you do i-- in the for loop it is not *infinite* but well yes it will run for a while lol
@nullreferenceexception9327
@nullreferenceexception9327 3 жыл бұрын
I crashed my pc when i did this lol
@feliwx4087
@feliwx4087 4 жыл бұрын
Oofh I'm quick lol
@joseruiz7122
@joseruiz7122 3 жыл бұрын
Your videos are informative but those fast forwards disorient me. I start to catch on but when you fast forward the steps I'm lost.
@BarioIDL
@BarioIDL 9 ай бұрын
if alex watched this 3 years ago, yandere simulator would be finished by now (jk you can't cure procrastination)
@developerakhter______0076
@developerakhter______0076 4 жыл бұрын
*I found 0.1 Differences in between* *C++ && C#*
@hj1ax
@hj1ax 4 жыл бұрын
lol, published 10 seconds ago.
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
Heartwarming: Stranger Saves Puppy from Hot Car #shorts
00:22
Fabiosa Best Lifehacks
Рет қаралды 18 МЛН
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 14 МЛН
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН