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.
Methods
- [Instructor] Until now, we have been using methods or functions from objects and those provided within the C-Sharp component. These methods allow logic to be encapsulated into a single col with a specific name and used more than once. In this lesson, we'll learn how to create methods. Go ahead and open up the exercise file for this lesson if you don't already have it open. This exercise file is a continuation from the last lesson. The only change is in the C-Sharp component. Firstly, I've added a random object on line 58 and assigned it to the variable, random. The random class is from the system namespace, which is imported by default with the C-Sharp component, and it allows us to create a random number. I do this on line 66 where, instead of creating a height from I and J variables, I have called the next method from the random object which will produce a random number, between one and eight, for the height. Now that…
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
-
-
-
-
(Locked)
Commenting2m 27s
-
(Locked)
Variables5m 1s
-
(Locked)
Numbers6m 36s
-
(Locked)
Strings5m 37s
-
(Locked)
Collections5m 34s
-
(Locked)
Arrays5m 32s
-
(Locked)
Comparing with operators5m 3s
-
(Locked)
Conditionals3m 30s
-
(Locked)
Logical operators6m 26s
-
(Locked)
Looping with the for loop5m 23s
-
(Locked)
Foreach looping4m 29s
-
(Locked)
Nested loops5m 12s
-
(Locked)
Methods6m 5s
-
(Locked)
Reference vs. value types5m 21s
-
(Locked)
Try and catch4m 14s
-
(Locked)
-
-