Is there a way to convert an array to a list of parameters..?
main(){
//"a" is an array or a list or some collection
myPrint(a.SomeMethod);
}
void myPrint(int a){
//Do Stuff to arguments
}
void myPrint(int a, int b){
//Do Stuff to arguments
}
void myPrint(int a, int b, int c){
//Do Stuff to arguments
}
I want to convert "a" into a parameter/argument list so it will automatically call the appropriate function.
main(){
int[] a = {1,2,3};
MyPrint(a);
}
void MyPrint(int... x){
//Do Stuff to arguments (accessing them by its index)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With