Let suppose i have 5 objects and each object contains double values.
I want to sum them up so that
double result=obj 1+obj 2+obj 3+obj 4+obj 5;
One way is to cast each object to double and then sum them up.
double result=(double)obj 1+(double)obj 2+(double)obj 3+(double)obj 4+(double)obj 5; //let suppose this cast works!
Is there any shorter way to do this?
You could put them into an array and use some LINQ onto it:
However, the best way would be keeping the doubles as doubles and don’t put them into objects.