"Dereference" var in C#

Posted by chris12892 on Stack Overflow See other posts from Stack Overflow or by chris12892
Published on 2011-01-15T18:25:31Z Indexed on 2011/01/15 18:54 UTC
Read the original article Hit count: 168

Filed under:
|

I have some code in C# that uses a structure as such:

            ArrayList addrs = new ArrayList();
                    byte[] addr = new byte[8];
        while (oneWire.Search_GetNextDevice(addr))
        {
            addrs.Add(addr);
        }

In this example, every element in the ArrayList is the same as the last device that was found because it would appear as though addr is passed out by reference and I am simply copying that reference into the ArrayList.

Is there any way to "Dereference" addr to only extract it's value?

It's also possible my assessment of the situation is incorrect, if that appears to be the case, please let me know

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET