vb.net - Function or Method with unknown number of parameters -
is there way create method unknown number of parameters?
and if case :
- how possible access them within method?
- do have same type?
yes & yes.
it possible, , of them must same type, if need pass various types use object datatype instead, , unbox them within function. use paramarray:
' accept variable number of arguments function sum(byval paramarray nums integer()) integer sum = 0 each integer in nums sum += next end function ' or use return statement c# dim total integer = sum(4, 3, 2, 1) ' returns 10 for more info see this
Comments
Post a Comment