Confused about intermediate string reading.

I’m currently saving profile data to a text file. I’m not using PlayerPrefs because I prefer to have control over where data is saved, and the portability of that data.

However, I’m finding string functions to be confusing for what I’m trying to do.

For instance, if I want to save values A and B in a text file that’s formatted like this:

A=1000
B=StringStuff

And then when I load the game back up, read all this and re-set my variables, how can I break all the read text into lines? They’ll already be broken into lines when I save the file, but I’m not sure how to then read them as lines after the fact. Moreover, it seems most string functions require defining very specific character positions. For instance, if I want to load the value of B, I’d look for the characters after “B=”… but I have no idea how I can possibly know the length beforehand, or figure it out between B and the line break so it doesn’t also start reading stuff from C.

I’m probably thinking of this the wrong way, but any help would be appreciated. I’ve looked up C# tutorials for string reading but they aren’t really helping out, as they aren’t clear or concise about doing exactly what I want, but are instead very vague with no good examples.

If someone could show me what it might look like to read two separate lines from a text file and set variables using those values, it’d be appreciated greatly. I already understand saving it though.

String.Split String.Split Method (System) | Microsoft Learn

ex:

var lines : string[] = myText.Split("

“[0]); // split into lines
for (var line in lines) // for each line
{
var parts = line.Split(”="[0]); // split at the =
var key = parts[0]; // eg “A”
var value = parts[1]; // eg “1000”

and you have to parse numbers etc. using int.Parse, float.Parse etc. if you need that.