0

Greetings,

I am 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 something in Asp.net that does this.

Thanks

1
  • maybe you could provide part of your actual code? it would help understanding more precisely what's your problem... Commented Jun 28, 2009 at 21:23

2 Answers 2

3

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".

Sign up to request clarification or add additional context in comments.

Comments

1

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.