I’m working on a game where I have a class for my character and a class to handle the GUI.
In the character class I have an array of structs which hold data about the character’s skills. I’m trying to access this array with the GUI class, to display the info about the skills.
To use one class in another one, I would need to initialize a new instance of it, which resets the values I might have changed in the meantime. Is there any way to pass that array? I can’t make it read-only because I still have to change the array. The array is also not being modified in the GUI class.
Also, in the future I’m going to save this data in XML or in a database. Is it a possibility to get the info out of these files every time I need them? Instead of having to work with passing the array on and things like that. Or even calculate everything server side?
Thanks in advance!
Simon.
If you want to have one array for the entire program, simply make the array
public static. If you want to have that class be able to access the array inside characters that you pass it, make the arraypublicor make a property for which thegetpart ispublic.