Saving and loading array (/list) of integers locally

Hi,

Currently I’ve spend many hours on trying to figure something out that should be very simple to do.
I’m trying to save and load multiple arrays, or lists, of integers locally.
This tutorial: How to Save and Load Your Players' Progress in Unity helped me a lot, but for whatever reason I can’t seem to implement it with arrays.

This is what I’ve currently made of it, but obviously it doesn’t work:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

public static class SaveLoad {
 
    public static List<int> list1 = new List<int>();
    public static List<int> list2 = new List<int>();
    //I want to have 50 lists (or arrays)   
          
    public static void Save(List<int> myList1, List<int> myList2) {
        SaveLoad.list1.Add(myList1);
        SaveLoad.list2.Add(myList2);
        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Create (Application.persistentDataPath + "/savedGames.gd"); 
        bf.Serialize(file, SaveLoad.list1);
        bf.Serialize(file, SaveLoad.list2);
        file.Close();
    }   
     
    public static void Load() {
        if(File.Exists(Application.persistentDataPath + "/savedGames.gd")) {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream file = File.Open(Application.persistentDataPath + "/savedGames.gd", FileMode.Open);
            SaveLoad.list1 = (List<int>)bf.Deserialize(file);
            SaveLoad.list2 = (List<int>)bf.Deserialize(file);
            file.Close();
        }
    }
}

Once that’s working I would also like to know the proper way of using this through another C# script, but first things first :slight_smile: .

Thanks in advance for your input!

List1 and List2 are lists of ints, not of int-lists. Instead of Add(), use =