devxlogo

Use a ParamArray as a true array

Use a ParamArray as a true array

Unlike VB6, in VB.NET the ParamArray keyword defines a true array object, which you can process using any of the methods of the Array class. For example, here’ s a function that evaluates the lowest value among those passed to the procedure, using the static Array.Sort method and then taking the element with the lowest index:

Function MinValue(ParamArray ByVal args() As Object) As Object    ' Sort the array, and then return its 1st element.    System.Array.Sort(args)    Return args(0)End Function

Also, note that the ParamArray keyword lets you define arrays of any type, not just objects.

devx-admin

Share the Post: