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

Comparing with operators

From the course: Grasshopper and Rhino: C# Scripting

Start my 1-month free trial

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…

Contents