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.

Arrays

Arrays

From the course: Grasshopper and Rhino: C# Scripting

Start my 1-month free trial

Arrays

- Lists are a great collection type to store, reorder, insert, and retrieve items. Another collection type that we'll come across in the Rhino API is the array. Unlike lists, arrays are a collection of items with fixed length, which is determined when they're initialized. So they're useful when we need to store a specific number of items that will not change. Arrays also provide a minor performance benefit. However, this is negligible in the scripts that we're building. So while we won't be creating them so much, we will be using them within the Rhino API. So let's have a look at the basics of using them. Go ahead and place a new C# component and open it up. To create an array we start with the object type. Let's create an array of integers. We then need to add open and close square brackets. This now defines the type as an array of integers and that's all that it can store. We then need to name it. Let's use my array.…

Contents