How to chnage lenght of an array?

I have a few arrays, and I want to change the length of them when a new guide opens and there is more item slots
public void Set(int num)
{
ReSet(num, slots, amount, I’d, used);
}
void ReSet(int num, GameObject slotsT, int amountT, int IdT, book usedT)
{
slots = new GameObject[num];
amount = new int[slots.Length];
Id = new int[slots.Length];
used = new book[slots.Length];
}
And so this will set the new length but the data is gone, I tried storing them in slotsT for example but no luck I can’t seem to put back the data, idk can you help me please!!?? Btw it’s for a game jam, so I need help fast

Arrays can not change their size. Once allocated an array has a fix size. There is the method System.Array.Resize which however does not resize the array at all but instead create a new array of the specified size and then it copies the old elements over into the new one.

However if you generally want to add / remove elements from a collection you should simply use a generic List instead. A list does use an array internally but it automatically manages the allocated array and performs a “resize” automatically if necessary.

List<GameObject> slots = new List<GameObject>();

To add elements to the list you would use the method “Add”. To remove an element you would use RemoveAt or Remove. Keep in mind that when removing elements in between the following elements are moved to fill the gap.