From the course: Grasshopper and Rhino: C# Scripting
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Looping with the for loop
From the course: Grasshopper and Rhino: C# Scripting
Looping with the for loop
- [Instructor] As in Grasshopper, we often need to perform a single or set of instructions for many items in a collection. Say, for example, we have a list of numbers. We may want to create a list of points or objects based on those numbers. In C sharp, we do this with a programming concept known as looping. Looping allows us to execute an instruction repeatedly until a certain condition is met. One common way of doing this in C sharp is with the for-loop, which comes in this format. We start with the keyword for and then three statements in parenthesis. The first statement is a variable, which is usually an integer. This variable is used in a condition each time the loop executes, and can also be used in a code with each loop. We then have a boolean expression, which is required to determine when the loop will end. Lastly, we have a step which will either increment or decrement each time the loop runs. With…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Commenting2m 27s
-
Variables5m 1s
-
Numbers6m 36s
-
Strings5m 37s
-
Collections5m 34s
-
Arrays5m 32s
-
Comparing with operators5m 3s
-
Conditionals3m 30s
-
Logical operators6m 26s
-
Looping with the for loop5m 23s
-
Foreach looping4m 29s
-
Nested loops5m 12s
-
Methods6m 5s
-
Reference vs. value types5m 21s
-
Try and catch4m 14s
-
-
-