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.
Comparing with operators
From the course: Grasshopper and Rhino: C# Scripting
Comparing with operators
Often in C sharp, we need to compare one object to another such as comparing the length of two lines, or the volume of two cubes. We can do this with comparison operators. Let's have a look at some of the basic comparison operators that we can use. Go ahead an open up the exercise file for this lesson if you don't already have it open and open up the C sharp component. When we compare two values, we'll get a Boolean returned. A Boolean is either one of two states, true or false. To create a Boolean variable, we need to use the bool keyword. So let's start by creating a Boolean variable named check and assign to it true. Then, lets output that variable by assigning check to A. Perfect, so we have out first Boolean from C sharp. Now let's use comparison operators to compare values which will return a Boolean. As you can see, we are inputting two points into the C sharp component. Let's compare the X value of these two points…
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
-
-
-