Using an array of
struct
items is exactly the same as using an array of
class
items, with a few exceptions.
You declare it the same way:
myStruct[] array = new myStruct[10];
But because all
struct
items are value types rather than reference types, you don't need to explicitly create each item as you would normally for a reference type:
myClass[] arrayOfReferenceType = new myClass[10];
for (int i = 0; i < 10; i++)
{
arrayOfReferenceType[i] = new myClass();
}
And you can then treat them pretty much the same after than, except ... when you use a reference type you use a copy of the reference, not the value. With a value type, you use a copy of the value, so any changes you make to it will not be reflected back in eth original.
This may help:
Using struct and class - what's that all about?[
^] - but there may be some stuff in there that's a little beyond your level at the moment.