In Vb.net I am trying to assign an array of structure to another array of same structure
Dim info() As assemblyInfo
Dim info2() As assemblyInfo
Structure assemblyInfo
Dim Name As String
Dim ClassTpys() As ClassTyp
End Structure
Private Sub test()
info2 = info
any change in ifo gets reflected in info2, this assignmnet is happening byRef.
I don't want any change in info to get reflected in info2 and vice-versa, after the assignme开发者_JAVA百科nt, how can I achieve this?
This is happening because info2=info
is just assigning the reference of info to info2. Try info.CopyTo(info2, 0)
Array is reference type so when you assign it you assign reference to it actually.
You need Array.Copy
method http://msdn.microsoft.com/en-us/library/k4yx47a1.aspx
精彩评论