I call the Clear method to set p to null. It can still be used in the following program and printed out ..
I call the Clear method to set p to null. It can still be used in the following program and printed out ..
Reply content:
I call the Clear method to set p to null. It can still be used in the following program and printed out ..
This is the C # code. If you directly transfer the code to p, it is equivalentPerson p1 = p
This is also true for js. In fact, the p in your function is just a small copy. If you want to directly import the reference, you need to addRef
Ah
Clear (ref p); static void Clear (ref Person p) {p = null ;}
The p in your Clear method (which is easily distinguished by p0 later) is not the input variable p. It points to the same memory as p, that is, to the same object, however, if you leave p0 blank in the method, p0 will no longer point to that object, which has no effect on p. The local variable p in the main method still points to the original object.