有没有办法将数组转换为参数列表..?
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
}
Run Code Online (Sandbox Code Playgroud)
我想将"a"转换为参数/参数列表,以便它自动调用相应的函数.
main(){
int[] a = {1,2,3};
MyPrint(a);
}
void MyPrint(int... x){
//Do Stuff to arguments (accessing them by its index)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6013 次 |
| 最近记录: |