The reference type is always mysterious because it stores the memory address. For a variable of the reference type, when you perform the value assignment operation, it is transmitted in the form of an address, when you operate on a reference type in a code segment, it will respond to the original object. Below I will talk about several common usage of the reference type:
Case 1: Will modifying the content element of a set variable affect the original object?
A: Yes, it will be reflected in the meta set.
Code:
List<Yinyong> yiyi = List<Yinyong> { Yinyong { ID = , Name = }, Yinyong { ID = , Name = ].Name = Console.WriteLine(yiyi[
Scenario 2: After defining a set variable, add some of its elements to another set, and modify its elements in another set, will it be reflected in the original set?
A: Yes, it will be reflected in the meta set.
Code:
List<Yinyong> yiyi = List<Yinyong> { Yinyong { ID = , Name = }, Yinyong { ID = , Name = <Yinyong> temp = List<Yinyong>=> i.ID == ( item =
Case 3: After defining the set variable, pass it as a parameter to other methods. Will the modification of this object in other methods be reflected in the original set of the original method?
A: Yes, it will be reflected in the meta set.
Code:
Main(<Yinyong> yiyi = List<Yinyong> { Yinyong { ID = , Name = }, Yinyong { ID = , Name = ModifySet(List<Yinyong>].Name =
Well, after mastering the above three points, we will be more comfortable writing code. Only by mastering the basic knowledge can we design better programs!