Is there an easier way to do this logical? It is used often and each time I have the impression that it is unnecessary.
if (x != y)
x = y;
In more time-consuming methods, you have to use variables so as not to recalculate them every time.
I think there has to be a better way than, for example:
var MyF = CheckSomething();
if (X != MyF)
X = MyF;
I have a class name ‘Person’. It has a property ‘Information’.
If you change the value of this field, the system performs calculations which, based on the value set, changes the contents of other fields in the system.
The problem is that I don’t want to change the contents of this field when it is identical to the value I have to compare.
Because it will slow down the program significantly.
And I wonder if there is an easier way than writing the above condition each time for each field that I want to check.
I can’t change this class, all I can do is set the property value.
The problem is that there are hundreds of these classes with dozens of properties