How can I best update and compare a struct?

Hello all

I’m using a struct to encapsulate a host of variables for a flocking algorithm. I have a class for the flock manager set up in the observer pattern that has all of my public variables that affect how the flock behaves.

Currently, I’m having to compare all of my variables to the stored info in my struct which is tedious to write. I have a huge f(a != struct. || b != struct.b || c != struct.c || d != struct.d) statement comparing 20 variables to each corresponding variable in the struct, and if any of them are different, it updates the struct.

Is there a better way to monitor a list of variables (they must be serialized so that I can adjust them for preview) without a gigantic if(a != struct. || b != struct.b || c != struct.c || d != struct.d) statement?

Or, even if I weren’t using a struct, how could I best monitor a large set of variables for changes?

Thanks in advance

Depends what you mean by “large set” but , I recommend a C# flags enum for your implementation. You can efficiently use bitwise operations to test for changes in the state of your flocking behavior. You can still use a struct and pack it all into one variable.