I have three doubles:
double[] accel = ne开发者_Python百科w double[3]
{
_Razor.Accel_X,
_Razor.Accel_Y,
_Razor.Accel_Z,
};
What's the most efficient way to find the largest of these in NETMF?
double result = accel[0];
if (accel[1] > result) result = accel[1];
if (accel[2] > result) result = accel[2];
return result;
i believe it is the usual way.
double max = max((max(accel[0],accel[1]),accel[2])
Probably just this, right?
double max = _Razor.Accel_X;
if (_Razor.Accel_Y > max)
max = _Razor.Accel_Y;
if (_Razor.Accel_Z > max)
max = _Razor.Accel_Z;
Or did you want something prettier?
The shortest solution with LINQ: accel.Max();
精彩评论