
May 23rd, 2002, 11:30 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
Array Addresses
<i><b>Originally posted by : Kerry (whelan_kerry@hotmail.com)</b></i><br />Hello,<br /><br />I have two arrays of structures. I define the arrays of structures as follows:-<br /><br /> //initialisation<br /> ConfigApp.Config.ConfigCollection[] orgColl;<br /> ConfigApp.Config.ConfigCollection[] newColl;<br /><br />where ConfigApp is the namespace, Config is the Class Name and ConfigCollection is the name of the structure,<br /><br />and I have also tried defining the arrays in this way:-<br /><br /> ConfigApp.Config.ConfigCollection[] newColl = new ConfigApp.Config.ConfigCollection[2];<br /><br />I call my Get function to fill orgColl (one of the arrays of structures).<br /><br />When orgColl is returned I copy it to newColl.<br /><br />I have done this using:-<br /><br /> orgColl.CopyTo(newColl,0);<br /><br />and I have tried:-<br /> <br /> newColl = orgColl;<br /><br />Then I pass the collection by reference to a function that makes changes to it,<br /><br /> public void MakeChanges(ref ConfigApp.Config.ConfigCollection[] newColl)<br /> {<br /> //newColl = orgColl;<br /> newColl[0].attValue[0] = "newName";<br /> }<br /><br />When I return to the calling function I find that both orgColl and newColl have the value 'newValue' inserted at the point .attValue[0]<br /><br />How can I set up the arrays so that the orgColl's value is not changed when newColl's value is changed.<br /><br />Thankyou for any help,<br /><br />Kerry<br />
|