In .NET 2.0 potresti sfruttare questa semplice funzione, che sfrutta ParamArray:
codice:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Console.WriteLine(MyMin(10, 15, 9, 10, 18, 88, 6, 19, 18, 16, 15, 11, 0, 16, -8, 9))
End Sub
Private Function MyMin(ParamArray valori() As Integer) As Integer
If valori.Length > 0 Then
Dim m As Integer = valori(0)
For i As Integer = 1 To valori.GetUpperBound(0)
If valori(i) < m Then m = valori(i)
Next
Return m
Else
Return Nothing
End If
End Function
Nelle versioni più recenti del framework potresti sfruttare le estensioni di linq e scrivere:
codice:
Private Function MyMin(ParamArray valori() As Integer) As Integer
Return valori.Min
End Function