Pass variable length of argument to a method.
How to pass variable length of argument to a method.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Akkiraju IvaturiPosted Aug 25, 2012, 5:05 PM
If you have your method structure, do pass it to me so that I can give you more clear answer
What I understood is as below:
void somemethod(variablelength)
{
}
If so why do not you make the method to accept a int type and then use it. The calling method just have to calculate the length of the argument and pass the length as a parameter along with the arguments or you accept the argument and then find the length in your method.
Anyways, there is some confusion in understanding and so I would recommend you to send the pseudo code to understand your requirement better.
satish kumarPosted Aug 25, 2012, 8:15 AM
VulpesPosted Aug 25, 2012, 6:35 AM
Akkiraju IvaturiPosted Aug 25, 2012, 2:01 AM
If you mean any number of arguments, you can use collection as a parameter and process on each item.
Can you clarify a little bit more on this?