I am processing significantly large amounts of data (millions of 300 variable plus objects). For an object to be added to the database, it must possess at least one of the 100 double? specified variables.
class RowObject {
double? var1 {get; set;}
double? var2 {get; set;}
//Another 98 double? variables declared
double? var100 {get; set;}
}
I have come up with two ways to check, adding all the variables together and seeing whether the result is greater than 0 or not null.
RowObject rO = new RowObject();
rO.var1 = 7250.345;
rO.var2 = null;
rO.var3 = 64.742l
//etc...
var sum = rO.var1 + rO.var2 + rO.var3 + ... rO.var100;
if (sum != null) {
//do something;
}
Or not surprisingly using an if statement
if (rO.var1 != null || rO.var2 != null|| ... rO.var100 != null) {
//do something;
}
Besides speed, 100 variables will reduce readability quite a bit, so if there is a better way that is negligibly slower but far easier on the eyes/understandable I would see that as a valid answer.