C# for loops
Jakman

In C# you will want to use for looping to make programming easier to do. This is how you will make a for loop to go through a number.

Use the keyword 'for' to start the for loop. Then encapsulate its contents in parentheses like a method. after that you need to initialize an interger value and terminate it by semicolons like done in the example. Then state what the for loop should last for. I have made it to where it will last while i is less than 10. Terminate that with a semicolon and move on. Then you need to increment what you are going through. adding '++' by a number value in C# increments that value by 1. So this value will go up by 1 every time the for loop loops. Then in curly brakets you contain what you actually want to loop. Here i have made the console write out the value of the i variable.
It will have the output of this

If you have any questions ask me.
Thank you for reading.

You are viewing a single comment. View All
08KINPLIX

:) C# is the first programming language is learned

Jakman

@08KINPLIX cool. It is the second language I learned.

08KINPLIX

@Jakman I use it with unity for game development

08KINPLIX

@Jakman My Icon and Pc background is the c# logo

Jakman

@08KINPLIX yeah i noticed. Cool. You wanna make a C# program together?

08KINPLIX

@Jakman Yes :) what do you want it to be about

Jakman

@08KINPLIX I was thinking of a math or scientific formula. What formula do you think it should be?

08KINPLIX

@Jakman Prime Numbers and Composite if thats a formula

Jakman

@08KINPLIX Ok then. How do i tell which is which?

08KINPLIX

@Jakman A prime number is a whole number that only has two factors which are itself and one. A composite number has factors in addition to one and itself. The numbers 0 and 1 are neither prime nor composite. All even numbers are divisible by two and so all even numbers greater than two are composite numbers.

Jakman

@08KINPLIX Ok cool. I will start a program and invite you to it.

08KINPLIX

@Jakman BTW dont expect me to be amazing at c# I use mainly for game development :)

08KINPLIX
Jakman

@08KINPLIX no problem. It cant be that hard :)

08KINPLIX

@Jakman btw this is a unity script:
transform.Translate(Vector3.right 8 Time.deltaTime);