How To Read Text Seperated By Commas Individually.

I am working on a save system for my game for which i only want to save the location of my player and a few other objects i.e. their x,y and z coordinates, i am able to save all of them to my save location using,

System.IO.File commands

but the problem is i am saving a particualr character’s pos in a single file seperated by commas, like playerpos.sav, which contains -40,0.5,26

but i cant figure out how to read these values separately?

any ideas?

//lets say objectA’s position is x:42, y:15, z:-64
var objectAposition = objectA.transform.position.x.ToString()+“,”+objectA.transform.position.y.ToString()+“,”+objectA.transform.position.z.ToString();
Debug.Log(“String value: “+objectAposition); // this will print in the console as “String value: 42,15,-64”
var words = objectAposition.Split(”,”[0]);
Debug.Log("As an array: "+words[0]+words[1]+words[2]);// this will print in the console as “As an array: 421564”
Debug.Log("Object A’s X position: "+words[0]);// this will print in the console as “Object A’s X position: 42”
Debug.Log("Object A’s Y position: "+words[1]);// this will print in the console as “Object A’s Y position: 15”
Debug.Log("Object A’s Z position: "+words[2]);// this will print in the console as “Object A’s Z position: -64”