using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

// Example class to save and load
[Serializable]
class PlayerData
{
    public int score;
    public string name;
}

class SaveLoad
{
    // Save method
    public void Save(PlayerData data, string fileName)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        using (FileStream stream = new FileStream(fileName, FileMode.Create))
        {
            formatter.Serialize(stream, data);
        }
    }

    // Load method
    public PlayerData Load(string fileName)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        using (FileStream stream = new FileStream(fileName, FileMode.Open))
        {
            return (PlayerData)formatter.Deserialize(stream);
        }
    }
}

