In C I’d have an array of structures then in the code somewhere create a pointer to one of the structures in the array.
This gives me speedy access both read and write to the structure. How do I do this in C Sharp? For example my structure:
public struct slot_struct
{
public float Health;
public float SetPower;
public slot_struct(float health,float setpower)
{
Health = health;
SetPower = setpower;
}
}
initialised like so:
public slot_struct[] Slots =
{
new slot_struct(100,25),
new slot_struct(50,10),
};
Then in code what is the way to access the data to read and write it. This example below only lets me read the data as it
seems to create a copy and not be a pointer or reference to the entry in the array:-
slot_struct Slot = Slots[1];
Slot.Health = 22.5f; // This doesn't actually write the data to the struct in the array which is my problem
Any ideas? in C I’d just use slot_struct *Slot = &Slots[1];