From the course: LINQPad Essential Training

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Snapshot the state of an object for comparison

Snapshot the state of an object for comparison - LINQ Tutorial

From the course: LINQPad Essential Training

Snapshot the state of an object for comparison

- [Instructor] When thinking about Dif tools, the first thought that comes to my mind is comparing the differences between two separate objects. However, there are times when we want to know the changes happening over time in the same object. Use the snapshot method to capture the state of an object. Then use the Dif tool to compare before and after states. Let's take a look at what we're doing here. On line four, I'm getting one of the elements out of my list of colors. And then here I'm dumping out that value. So you can see the original state of this object. Then, on line six, I call you Util.Snapshot. I pass in the reference to my web color class, and then I get a snapshot variable here. Now I modify the original object by changing the red and green values, and then I use Dif. This time I'm diffing the colorSnap and the color. So let me comment out line five. Run the code. And here you see the values that have changed…

Contents