public static MyArray stats( [Parameter("input for computation")] MyArray data ) { double total = 0.0; double totalsq = 0.0; if (data.size < 2) { throw(new Exception("At least data points are needed")); } for (int i = 0; i < data.size; i++) { total += data[i]; totalsq += data[i] * data[i]; } MyArray values = new MyArray(2); values[0] = total / data.size; values[1] = totalsq / data.size - values[0] * values[0]; return(values); }
static void Main(string[] args) { int[] mas = new int[] { 23, 23, 23, 2, 2, 6 }; Console.WriteLine("--------Array-----------"); foreach (int item in mas) { Console.Write("{0} ", item); } Console.WriteLine(); ArrayList arrayList = new ArrayList(); arrayList.AddRange(mas); arrayList.Add(12); Console.WriteLine("-----------ArrayList------------------"); foreach (int item in arrayList) { Console.Write("{0} ", item); } Console.WriteLine(); Console.WriteLine("-----------MyArray------------------"); MyArray myArray = new MyArray(); Console.WriteLine(myArray); foreach (var item in myArray) { Console.Write("{0} ", item); } Console.WriteLine(); Console.WriteLine("-----------MyArray------------------"); foreach (var item in myArray) { Console.Write("{0} ", item); } Console.WriteLine(); //Test test = new Test(); //Console.WriteLine("-----------MyArray------------------"); //foreach (var item in test) // Console.Write("{0} ", item); //Console.WriteLine(); }
public static MyArray EchoArray( [Parameter(" argument to be echoed")] MyArray Echoee ) { return(Echoee); }