Funtion taking n number of args

mmb

Active member
Joined
Aug 1, 2004
Messages
42
Programming Experience
1-3
Do anybody know how can a Function can take n number of arguments.

Help required.
Bye
 
use the optional keyword such as

VB.NET:
 friend function MyFunction(optional byval MyInt As integer = 1, optional byval OtherInt As integer = 2) as integer
 'do stuff
 end function
 
Sir JuggaloBrotha,

The code u have written above is still accepting maximum 2 args and minimum zero args.
I want that the arguments of a Function to be set at run time.

Is this possible?
 
i'm just curious as to why you would need to at run time set the number of arguements for a function

and overloading/optional are the only way i know of to change the number of arguements, but you cant do that at runtime either
 
If all the arguments are of the same type, you could use an array or arraylist.

I'm also curious as to what you're trying to accomplish. You often get a better answer if you give some background about the question :).
 
I have made a generic class for making DataGrid Functionality(Load,Insert,Update,delete).

In one of the functions of the class ,tables name is to be passed. Table can be one or it can be 5 or so on. For this the number of args of the function should be dynamic.

If there s any way out here do let me know.
 
Like Paszt said use an array/list. You could also use a delimiter string, but there wouldn't really be any difference.
 
Back
Top