🌍 FREE C# Beginner Complete Course! ruclips.net/video/pReR6Z9rK-o/видео.html 🔴 Watch my Complete FREE Game Dev Course! 🌍 ruclips.net/video/AmGSEH7QcDg/видео.html 📝 C# Basics to Advanced Playlist ruclips.net/p/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!
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.
You're very quickly become the best Unity channel on RUclips, you know? No fuss, no messing about... straight in to it covering the important information in a digestible way. Nice one.
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!!!
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.
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 :)
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!
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.
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.
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"
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.
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.
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.
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
@@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!!
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.
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.
🌍 FREE C# Beginner Complete Course! ruclips.net/video/pReR6Z9rK-o/видео.html
🔴 Watch my Complete FREE Game Dev Course! 🌍 ruclips.net/video/AmGSEH7QcDg/видео.html
📝 C# Basics to Advanced Playlist ruclips.net/p/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!
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.
Yup, if performance is a concern then caching the length is a nice an easy way to get some ms
This is definitely good for my inventory script which is taking up approx. 0.27ms rn. Scalability wise, this’ll help.
Commenting to remember this later
thanks, this is going into my collection of performant code :D
Makes sense. Thanks for this.!
You're very quickly become the best Unity channel on RUclips, you know? No fuss, no messing about... straight in to it covering the important information in a digestible way. Nice one.
Thanks!
This helps tremendously with the project I’m working on right now, thanks!
Best vedio on c# loops I've seen everrr
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!!!
Thank you so much! I've been struggling with the concept of loops and I think it is starting to click.
Finally completed all videos in this playlist 🎉. Thanks for this invaluable playlist sir. 🙌🏻
But please can you make a video on switch statements. 🙏🏻😇
thanks for the info was so useful, very well explained.
We need more videos on this series🙌
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.
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 :)
you can scan list in reverse order to remove element
Great vid. Can you do Events in the future?
I have covered Events here ruclips.net/video/OuZrhykVytg/видео.html
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
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
also very nice tip on how to remove an object in a list
my brain is boost with loop...make this basic tutorial it real help us who are new in programming
Thank you
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!
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.
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.
Thank you Code Monkey🙂🙂
I'm waiting for next video please upload as quickly as possible?
im new at programming im using visual studio and unity looks so alike
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"
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.
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.
Hi dude. Can u make trade system for mmorpg games? Thanks for helps.
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.
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
@@CodeMonkeyUnity That's what I was wondering. Thanks.
I just get an ad of one of your videos... in your video xd
Really? Interesting...
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.
Does break 2; work in c# for breaking 2 levels or even more? Im from the php world and we have this syntax there. :-)
no, unfortunately you can only break the loop you are in, not the outer loops
@@sagiziv927 ok, thx for the answer :-)
Could you do tutorials for top down shooter game?
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
Code Monkey thanks!
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 :/
The if code block will only run once and the while code block will run for as long as i is under 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!!
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.
you mean It not runs second time* (not "second loop") at all ? 0_o 13:36
Make video about making amionation
dai craft make me a sandwich
@@spe.z.artist what about tea?
Are you writing that while sleeping
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.
It's actually painful you don't use the dark theme xD
Sorry but dark theme is painful for me, I can't look at it for more than 30 seconds
@@CodeMonkeyUnity I feel you probably get that comment alot :D
Well if you do i-- in the for loop it is not *infinite* but well yes it will run for a while lol
if alex watched this 3 years ago, yandere simulator would be finished by now
(jk you can't cure procrastination)
*I found 0.1 Differences in between*
*C++ && C#*
I crashed my pc when i did this lol
lol, published 10 seconds ago.
Oofh I'm quick lol