Getting my array[1] to get values from another array

Hi… I’m trying to get my array to get values from another array of the same type.
Here’s my code that works

public Skill[]    allSkills; 

void Start () 
{
    allSkills = new Skill[5];    // this is a class of array
}

void GetArray ()
{
    string blah = PlayerPrefs.GetString("CatSkills");
// if you don't know json, just think of the right side as another class of array
    allSkills = JsonConvert.DeserializeObject<Skill[]>(blah);

// the above can also be translated as
    Skill[] skill;
    allSkills = skill;
}

While the above works, it only applies the values on allSkills[0]. And after I deleted my PlayerPrefs, it turns my allSkill’s array size to null.

How do I make it maintain my array size and apply the values to ‘allSkills[1]’?

thats because allskills is just a pointer to the first object in the array

your going to want to for loop through the array to do something to each item in it

list<Thing> mylist;

foreach( Thing item in allskills)
{
mylist.add(deserialize(item);
}

you now how have a list of deserialized items.

if you literally just want to copy you can do

mylist.addrange(allskills);

Finally found an answer. This is for whoever that wants to know.

    public class Skill {
        //....variables
    }    
    
    public List<Skill> allSkills    = new List<Skill>();
    public Skill[] skillArray;
        
    void GetArray ()
    {
       string blah = PlayerPrefs.GetString("CatSkills");
       JsonConvert.DeserializeObject<List<Skill>>(blah).CopyTo(skillArray, 0);
    }