Hello everyone,
Supposing I am writng a web services client using managed code. My question is what is the differences between passing by value and passing by reference, when we pass parameter to a web services web method call?
My confusion is, in traditional senses, passing by reference means passing only a pointer, and modification is impacted on the original object. Passing by value means passing a new copy of original object, and modification is not impacted on the original object. -- But for web services, no matter pass by value or pass by reference of an object, I think it is always made a new copy and not pointer across the network to web services server (since pointer address is only meaningful for local process on local machine)?
What is the actual differnces between passing by reference and passing by value when making a web services call?
thanks in advance,
George
George GeorgePosted Oct 1, 2008, 4:28 AM
Ryan AlfordPosted Sep 30, 2008, 3:45 PM
George GeorgePosted Sep 30, 2008, 7:50 AM
Thanks Ryan!
Could I just simply understand the differences between passing value type parameter between passing reference type parameter is -- if pass by reference, the modified result is copied back during web services response? If passed by value, no copy-back during web services response?
regards,
George
Ryan AlfordPosted Sep 29, 2008, 10:28 AM
on the web service side, this....
[WebMethod]
public void PassingByReference(ref string test)
{
s = "This is passing by reference";
}
is the same as this...
[WebMethod]
public void PassingByReference(string test)
{
s = "This is passing by reference";
}
however, if you pass by reference, on the return, the value will be updated as it normally would when passing by reference. So basically, you are not passing a pointer to the web service, but .Net updates the pointer on the return as it normally would when passing by reference.