split string and haskey problems

Sorry to post again but there is no answer somwhere else.

  1. I would need to find more than one playerpref strings with continuing number

savedstring1
savedstring2
savedstring3

I was thinking of

for (int cnt = 0; cnt < 50; cnt++) {

if(PlayerPrefs.HasKey(“savedstring”[cnt])) {
Debug.Log(“savedstring”[cnt]);
}}

Such solutions doesn’t work. Ideas how to inf that prefs?

  1. I know it’s possible to split strings, but what to do next? I need to split the string and turn back the parts in “normal” strings. Ideas?

for (int cnt = 1; cnt < 51; cnt++) {

if(PlayerPrefs.HasKey(“savedstring” + cnt)) {
Debug.Log(“savedstring” + cnt);
}}

Nice ty… Am I right that I can’t convert split string parts to int, float, string again?

I was reading much about splitstring but any forum entry was just about showing scoredata. Is string.split just for kind of print use?

It is possible to use split and then put it together again. Let say you have the string:

string s =

string s = "This is 1 string";

string[] sArray = s.Split(' '); //we split at spaces
s = "";

for(int i < sArray.Length - 1; i > -1; i--)
{
     s += sArray[i];
}

Debug.Log(s);
//output: string 1 is this

It is possible to convert strings to float and int’s and the other way around in C#. If you need something more complex to split up the strings you should look at regular expressions.

I just store xyz positiondata in a string and save the string playerprefs. So I search again that strings (you helped me out).

Now I need to “use” this xyz data seperate again to bring the object to the saved position. I just wrote all in one string to have better overview.

So I need to convert the z, x, z string parts back to float…

You can use float.TryParse(string, out float)

This was definately my hardest lesson since I started my project. I get back my arrays now and just (I hope it’s a ~just~) need to convert to string, int, float.

Really big TY to you - you saved my happyness to start 2013 tomorrow, cos it was my goal to save my stuff before new years day. :wink: