using System;
class parArray
{
public static int Min(params int[] array)
{
int currentMin = array[0];
foreach (int i in array)
{
currentMin = Min(currentMin, i);
}
return currentMin;
}
public static int Min(int lhs, int rhs)
{
return lhs < rhs ? lhs : rhs;
}
}
class Program
{
static void Main()
{
Console.WriteLine(parArray.Min(72, 35, 23, 47, 58));
Console.ReadKey();
}
}
|
Class parArray
Public Shared Function Min(ParamArray array As Integer()) As Integer
Dim currentMin As Integer = array(0)
For Each i As Integer In array
currentMin = Min(currentMin, i)
Next
Return currentMin
End Function
Public Shared Function Min(lhs As Integer, rhs As Integer) As Integer
Return If(lhs < rhs, lhs, rhs)
End Function
End Class
Class Program
Private Shared Sub Main()
Console.WriteLine(parArray.Min(72, 35, 23, 47, 58))
Console.ReadKey()
End Sub
End Class
|