From the course: Advanced C#: Language Features
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Equality testing - C# Tutorial
From the course: Advanced C#: Language Features
Equality testing
- [Instructor] Sometimes when you define a custom class, you're going to need to be able to compare instances of that class to other instances to see if they have what's called value equality. In other words, you want to see if the values of all the properties of the two instances are the same. And in this example, we'll see how to do that. So let's open the program code in the Comparing folder. Now, by default, .NET doesn't support comparing two custom types to each other in this way. In this example, I have a class named Point2D, which contains X and Y properties along with some code that creates two points and then compares them using the equals function and the double equal and not equal operators. Now let's go ahead and just run the code as it is. So I'm going to right click and open up the integrated terminal. Alright, and let's run this. And if I run the code as is, you can see that the result…