VB. NET transmits values by type or by reference, (byval byref) C # has an out.
Sometimes I will ask a small question during the interview. Hey hey, check if you are familiar with C # basic syntax.
For example
Public void XXX (byval form as form)
And
Public void XXX (byref form as form)
What is the difference? In fact, it is very simple to correspond to C ++ is void XXX (Form * form) and void XXX (Form ** form)
The so-called pass by value and transfer by reference all have a basic problem: Who's value and who's address.
In the preceding two methods, the first value is the address of the form object. So in the first method, you write
Form. xxx = ZZZ // you can change the value of the original form object.
Form = new form ()
Form. xxx = YYY;
In fact, the original form value is not affected.
The second one is different. It passes the address, so he can change the original form value.
It is even more strange to put this problem in WebService.
[Webmethod ()]
Public void XXX (byval P as person)
[Webmethod ()]
Public void YYY (byref P as person)
We all say that WebService is stateless, so what is the difference between the first method and the second method? If the first method is similarCodeCan he affect the status of the object that the client sends to him? What about the second one?
Looking at Microsoft's implementation, we found that he had done a lot of weird code.
Look at the WSDL of his second method. It is clear that the return is void, and he should return an object for you.
<Soap: Body>
<Helloworldpersonresponse xmlns = "http://tempuri.org/">
<P>
<Name>String</Name>
</P>
</Helloworldpersonresponse>
</Soap: Body>
Then what operations does the client proxy do? Haha. The following code
Public sub helloworldperson (byref P as person)
Dim results () as object = me. Invoke ("yyy", new object () {p })
P = ctype (results (0), Person)
End sub
Ms is so trampled on the standard, huh, huh