C#: When adding the same object to two List<object> variables, is the object cloned in the process?

后端 未结 7 1172
伪装坚强ぢ
伪装坚强ぢ 2021-01-01 19:28

I have something similar to this:

// Declarations:
List list1 = new List();
List list2 = new List

        
7条回答
  •  情深已故
    2021-01-01 20:14

    Yes that is expected. Only the reference to the object is added. Not the reference itself or a copy.

提交回复
热议问题