C# Create high score text file and reorder the results
<p>I'm trying to create  a text file containing the players' scores of a hangman game. The structure of the text file should follow the order: number. name score (e.g. 1. Helen 2500). I tried to split the line so that I can introduce the data into a specific array for name and score so that I can compare the results and reorder them (the numbers remain the same: 1, 2, 3, etc.) but it doesn't work. I don't get errors but the building stops at this function because of an incorrect use of the array v[]. What do you suggest me to do to make it work?</p>

<p>[code]</p>

<pre><code>private void New_Score(int score)
        {
            int k=0, i;
            char[] sep = new char[] { ' ', '\n', '.' };
            string line, aux1, aux2;
            string n=null, s=null;
            n = textBox1.Text;
            s = Convert.ToString(score);
            string[] part=null, nr=null, name=null, result=null;
            file_path = @"D:\Visual Studio 2005\Projects\WindowsApplication2\WindowsApplication2\Resources\HighScore.txt";
            StreamReader f = new StreamReader(file_path);

            while ((line = f.ReadLine()) != null)
            {
                part = null;
                v = null;
                part = line.Split(sep);
                i=0;
                foreach(string c in part)
                {
                    v[i]= c;
                    i++;
                }
                nr[k] = v[0];
                name[k] = v[1];
                result[k] = v[2];
            }

            for (i = 0; i &lt; k; i++)
                if (string.CompareOrdinal(s,result[i]) == 1)
                {
                    aux1 = s;
                    s = result[i];
                    result[i] = aux1;

                    aux2 = n;
                    n = name[i];
                    name[i] = aux2;
                }

            for (i = 0; i &lt; k; i++)
            {
                line = nr[i] + ". " + name[i] + " " + result[i] + "\n";
                File.WriteAllText(file_path, line);
            }
        }
</code></pre>

<p>[/code]</p>
