I don't understand.
How is your code different than the code I posted below (which behaves
"correctly")?
========================
using System;
namespace ArrayAssignment
{
class Foo // some class to put in the array
{
private long myId;
public Foo( long aId)
{
myId = aId;
}
public long ID
{
get { return myId;}
set { myId = value;}
}
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
Foo[] aFoo1;
Foo[] aFoo2;
long i;
// initialize first array
aFoo1 = new Foo[10];
for (i = 0; i < 10; i++)
{
aFoo1[i] = new Foo(i);
}
// second array references first array
aFoo2 = aFoo1;
//check values
Console.WriteLine(aFoo1[3].ID); // should be same as index = 3
Console.WriteLine(aFoo2[3].ID); // should be same as aFoo1 = 3
aFoo2[3].ID = 27;
//check values
Console.WriteLine(aFoo1[3].ID); // should be new value = 27
Console.WriteLine(aFoo2[3].ID); // should still be same as aFoo1 = 27
// make a new array
aFoo2 = new Foo[aFoo1.Length];
for (i = 0; i < aFoo2.Length; i++)
{
aFoo2[i] = new Foo(i + aFoo2.Length);
}
//check values
Console.WriteLine(aFoo1[3].ID); // orignal array has not changed = 27
Console.WriteLine(aFoo2[3].ID); // now have new array value is index +
length = 13
aFoo2[3].ID = 100;
//check values
Console.WriteLine(aFoo1[3].ID); // orignal array has not changed - 27
Console.WriteLine(aFoo2[3].ID); // should be new value = 100
}
}
}
----- Original Message -----
From: "Kerry Whelan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 24, 2002 2:53 AM
Subject: Re: [DOTNET] Array addresses
> I had tried this:-
>
> ConfigApp.Config.ConfigCollection newColl = new
> ConfigApp.Config.ConfigCollection[orgColl.Length];
>
> already, but it has the same effect as newColl = orgColl;
>
> Any other ideas?
>
> Kerry
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
>
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.