tags:

views:

157

answers:

2

Greetings,

I'm passing a form to a class in Asp.net and was wondering is there anyway to pass the number of fields from the form to the class?

Currently I have

foo(param1, param2, param3, param4, param5) {};

wondering if I could just do

foo() { formData.split }

Obviously I could just make a data object and pass that to the class. Just wondering if there is already soemthing in Asp.net that does this.

Thanks

+3  A: 

I'm not sure I understood correctly, but what about

void foo (params object[] args){
}

where params is the keyword for "arbitrary number of arguments".

Paolo Tedesco
+1  A: 

Im not sure if i understand you're question, but if you want to get the number of fields (i.e. private variables) of a class, you can use the Reflection class.

If you want to pass a variable amount of parameters to a function, you can use the params keyword (or __arglist, but forget this one)

Henri