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.
Reference vs. value types
From the course: Grasshopper and Rhino: C# Scripting
Reference vs. value types
- [Instructor] Earlier in the course, I introduced the idea that an object, can either be a value or reference type object. So let's take a closer look at these two types. These types differ in the way that they store data in memory. A value type will store data within its own memory allocation, in a single space in memory. What this means is that when we allocate a value type, like the number 100, to a variable named, i, for example, the data 100 is stored directly with the variable i in memory. This makes the data fast to access. The impact that this has on our code, is that if we were to make another variable, say j, which was to equal i, it would basically create a copy of that value, which will be stored in memory with the variable j. And the location for i is unaffected. Value types, are those created with a struct instead of a class, like an int Boolean or double. With reference types, the data is not stored…
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)
-
-