Get minimum and maximum values from an array

double[] NumberArray = {
 1,
 2,
 3,
 9,
 8,
 7,
 System.Math.PI
};
if (NumberArray.Length > 0) {
 double[] SortArray = NumberArray.Clone;
 Array.Sort(SortArray);
 double MinValue = SortArray(0);
 double MaxValue = SortArray(SortArray.Length - 1);
 SortArray = null;
}

No comments:

Post a Comment