Tim Hastings - NonHostile (because there's no need)

Weblog and collection of geeky articles.

  Home :: Who? :: Contact :: Links :: Subscribe subscribe
Privacy Risk With Internet ExplorerNow Witness the Power of This Fully Armed and Operational Debian NSLU2More Industrial Revelations with Mark Williams - God Be Praised!!

A really useful feature of VB.Net is to be able to define a sub or function with a variable array of parameters. It often seems unfair that a language's own interal functions allow an unlimited number of parameters, and yet your own must explicitly declare them. VB6 supported optional parameters which is still supported in .Net, but this feature's much better.

    Public Function Concat(ByVal ParamArray Args() As String) As String

        Dim objSB As New Text.StringBuilder

        For i As Integer = 0 To Args.GetUpperBound(0)

        Return objSB.ToString

    End Function

    Console.WriteLine(Concat("xyz", "123", "3453"))
    Console.WriteLine(Concat("a", "b", "c", "d", "e", "f", "g"))

202 comments, VB.Net, Wednesday, December 8, 2004 13:24

Timeline Navigation for VB.Net posts
VB.Net: Base64 Encoding and Decoding in One Line of Code (made 11 weeks later)
VB.Net: Creating Functions with a variable Number of Parameters using ParamArray (this post, made Wednesday, December 8, 2004 13:24)
VB.Net: Loading a File (or any other stream) into a Memory Stream (made 2 weeks earlier)

Thanks for the article simple but very useful - helped me at the right time.

Posted by: Devarley on Wednesday, June 9, 2010 02:02

Post a Comment
Name:  Home page and email address are optional.
  Email addresses will not be displayed or spammed!
Remember these details
Home Page:
Comments cannot contain HTML, URLs will be formatted into hyperlinks.
I reserve the right to remove any comments for any reason.