Count(Values: Array): Integer;
Count(Values: System.Array): integer;
Values. Array.
The Count property returns the number of non-empty elements in the array.
To get the number of empty array elements, use the IStatistics.CountBlank method.
To execute the example add links to the MathFin, Stat system assemblies.
Sub UserProc;
Var
mathF: Math;
Ar: Array Of Double;
count, i: Integer;
value: Double;
st: Statistics;
Begin
// Create array with random number of elements
mathF := New Math.Create;
count := mathF.RandBetweenI(1, 100);
Ar := New Double[count];
// Populate array with values that are greater than 0.5
For i := 1 To count - 1 Do
value := mathF.Rand;
If value > 0.5 Then
Ar[i] := value;
Else
Ar[i] := Double.Nan;
End If;
End For;
// Display information about created array in the console window
st := New Statistics.Create;
Debug.WriteLine("Total number of elements in array: " + count.ToString);
Debug.WriteLine("Number of non-empty elements in array: " + st.Count(Ar).ToString);
Debug.WriteLine("Number of empty elements in array: " + st.CountBlank(Ar).ToString);
End Sub UserProc;
After executing the example the console window displays information about the array: total number of elements, the number of non-empty elements and the number of empty elements.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.MathFin;
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
mathF: Prognoz.Platform.Interop.MathFin.Math;
Ar: Array Of Double;
count, i: Integer;
value: Double;
st: Statistics;
Begin
// Create array with random number of elements
mathF := New Prognoz.Platform.Interop.MathFin.Math.Create();
count := mathF.RandBetweenI(1, 100);
Ar := New Double[count];
// Populate array with values that are greater than 0.5
For i := 1 To count - 1 Do
value := mathF.Rand();
If value > 0.5 Then
Ar[i] := value;
Else
Ar[i] := double.NaN;
End If;
End For;
// Display information about created array in the console window
st := New Statistics.Create();
System.Diagnostics.Debug.WriteLine("Total number of elements in array: " + count.ToString());
System.Diagnostics.Debug.WriteLine("Number of non-empty elements in array: " + st.Count(Ar).ToString());
System.Diagnostics.Debug.WriteLine("Number of empty elements in array: " + st.CountBlank(Ar).ToString());
End Sub;
See also: