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

Methods

From the course: Grasshopper and Rhino: C# Scripting

Start my 1-month free trial

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…

Contents