How to save/load the Y-Coordinates of Instantiated Objects

I have a grid of cubes that was too large for me to simply copy and paste. In order to make it, I needed to array a prefab using a for loop. These cubes are then translated up and down by the player using Raycasting. What I am trying to do is re-read the array, making a CSV of the Y-values with their changes. They don’t move along any other axis, so I don’t need to save them.

The intention is that later, the player can load their CSV and have the cubes return to the saved values.

This is the code I have to create the array, in case their is a better way to create it that would allow this functionality. As it stands, it saves the values, however this is only when everything loads.

using UnityEngine;
using System.Collections;
using System.IO;

public class FloorArray : MonoBehaviour{

    public GameObject defObject;
    GameObject defObject2;	

    public float xVal = -17.14359f;
    public float yVal = -1.830479f;
    public float zVal = -1.685268f;   

    //Variables used to save the coordinate values
    public string[] arrVector1 = new string[150]; 
    public string arrVector2;
    public Vector3 Vector;
    float fArr;

void Start () {
		defObject = Instantiate(Resources.Load("Prefabs/FloorPin")) as GameObject;
        for (float x = 0; x < 15; x += 0.1f)
            for (float z = 0; z < 10; z += 0.1f)
                Vector = new Vector3(xVal - x, yVal, zVal + z);
                arrVector2 += yVal + ", ";
                defObject2 = Instantiate(Resources.Load("Prefabs/FloorPin"), Vector, Quaternion.Euler(270, 0, 0)) as GameObject;
            fArr = x * 10;
            arrVector1[(int)fArr] = arrVector2;
        //Saves the generated array into a string
        string[,] strName = new string[15,10];
        strName[0,0] = arrVector1.ToString();

void save()
        System.IO.File.WriteAllLines(@"E:\Test\TestFile.csv", arrVector1);

I have attempted to use the method outlined on this website, however
System.IO.File.WriteAllLines(@"E:\Test\TestFile.csv", arrVector1);
doesn’t accept it, giving me an error CS1502 (Best overloaded method match has some invalid arguments).

If anyone has any ideas it would be greatly appreciated.

See this [documentation][1] from microsoft. In function WriteAllText is two argument of type string. In your case - second argument is array of string. This change to string. For example, see my code below(write on CSharp):

 public void save() {
  string tempStr = ""; //your string for file
  for(int i = 0; i < arrVector1.Length; i++) {
   if (tempStr!= "") { //add new line in our variable
    tempStr = tempStr + "

tempStr = tempStr + arrVector1*;*
System.IO.File.WriteAllLines(@“E:\Test\TestFile.csv”, tempStr);
[1]: File.WriteAllText Method (System.IO) | Microsoft Learn