Hello,
I believed that structure is a reference type.
- public struct struct_A
- {
- public int struct_member1;
- public int struct_member2;
- public int struct_member3;
- }
- struct_A [] arrA_1 = new struct_A [7];
- struct_A [] arrA_2 = new struct_A [7];
- List
lst_A = new List (); - // list initialization
- for (int i = 0; i < arrA_1.Length; i++)
- {
- lst_A.Add(arrA_1[i];
- lst_A.Add(arrA_2[i];
- }
Then I assign arrA_1[0]. struct_member2:
- arrA_1[2].struct_member2 = 10;
- int check_value = lst_A[0].struct_member2
The check_value should be 10, but it isn't. Why ?
Thanks in advance.


Pavel106 reputationPosted Sep 28, 2016, 8:28 AM EDT
Ehsan SajjadRank #512 · 4.8K reputationPosted Sep 28, 2016, 1:01 PM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Sep 28, 2016, 1:47 PM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Sep 28, 2016, 7:10 PM EDT
Pavel106 reputationPosted Sep 28, 2016, 11:53 PM EDT