How can I create a collection of references in C#
Posted
by Jonathan Kaufman
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan Kaufman
Published on 2010-05-12T23:07:19Z
Indexed on
2010/05/12
23:14 UTC
Read the original article
Hit count: 268
Ok I am having a cross language hiccup. In C# with it's great collections like List and I have:
a Map class with properties of:
List
<byte[]>
Images;
List<Tile>
Tiles;
a Tile Class of:
byte[] ImageData;
int X;
int Y;
Now I want to add an image to the Map class and have the ImageData property of the Tile Classes to "reference" it. I have discovered I can't just assign it Images[0]. You can't have a reference to an object of a List.
My fix was to create a Dictionary. Is this the best way or can I somehow have a "pointer" to a collection of objects?
© Stack Overflow or respective owner