Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pass param to method by ref?

Status
Not open for further replies.

redsss

Programmer
Mar 17, 2004
72
US
I am calling a webservice that will return multiple integer values, so I assume the best way to do so is pass the variables by ref, right?

So I define my variables, and call the webservice...
Code:
  int foo;
  ret = mywebservice.mymethod( ref foo);
But I get a compilation error: "use of unassigned local variable 'foo'"

Since the purpose of the webservice function is to populate foo, is there a way to call the function without first setting the value of foo?
 
Change it from a ref parameter to an out parameter. The method you're calling is then responsible for instantiating/initializing it.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top