How can i loop through Two Lists <float> in another List? And then put the strings to a key? Almost working
<p>In the for loop i did:</p>

<pre><code>string[] xFrames = new string[wocl.Count];
            string[] yFrames = new string[wocl.Count];
            List&lt;float&gt; Xframes = new List&lt;float&gt;(wocl.Count);
            List&lt;float&gt; Yframes = new List&lt;float&gt;(wocl.Count);
            for (int i = 0; i &lt; wocl.Count; i++)
            {
                string X = xFrames[i] = string.Format("Frame_X_{0} ", i + 1);
                string Y = yFrames[i] = string.Format("Frame_Y_{0} ", i + 1);

                for (int j = 0; j &lt; wocl[i].Point_X.Count; j++)
                {
                   // xFrames[i] += string.Format("{0},", wocl[i].Point_X[j]);
                   // yFrames[i] += string.Format("{0},", wocl[i].Point_Y[j]);
                    Xframes.Add(wocl[i].Point_X[j]);
                    Yframes.Add(wocl[i].Point_X[j]);

                }

                //xFrames[i].Trim(",".ToCharArray());
                //yFrames[i].Trim(",".ToCharArray());

                setting_file.SetListFloatKey(X, Xframes);
                setting_file.SetListFloatKey(Y, Yframes);

            }
</code></pre>

<p>The result in the text file is:</p>

<pre><code>Frame_X_1 =325,332,322,332,325
Frame_Y_1 =325,332,322,332,325
Frame_X_2 =325,332,322,332,325,318,332,322,332,325
Frame_Y_2 =325,332,322,332,325,318,332,322,332,325
Frame_X_3 =325,332,322,332,325,318,332,322,332,325,318,332,322,355,325
Frame_Y_3 =325,332,322,332,325,318,332,322,332,325,318,332,322,355,325
Frame_X_4 =325,332,322,332,325,318,332,322,332,325,318,332,322,355,325,318,388,322,355,325
Frame_Y_4 =325,332,322,332,325,318,332,322,332,325,318,332,322,355,325,318,388,322,355,325
</code></pre>

<p>Not sure why the numbers arel ike that on the right after the =
Should be in each Frame x and y same numbers/coordinates.</p>

<p>Like in  Frame_X_1 and not at Frame_X_4
or not like in Frame_X_2 For some reason its keeping adding the numbers.</p>

<p>The setting_file im using is connected to the OptionsFile class:</p>

<pre><code>/*----------------------------------------------------------------
 * Module Name  : OptionsFile
 * Description  : Saves and retrievs application options
 * Author       : Danny
 * Date         : 10/02/2010
 * Revision     : 1.00
 * --------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Configuration;


/*
 *  Introduction :
 * 
 *  This module helps in saving application options
 * 
 * 
 *  Typical file could look like this:
 *  user_color=Red
 *  time_left=30
 *  
 * 
 * 
 * 
 * 
 * */

namespace DannyGeneral
{
    class OptionsFile
    {
        /*----------------------------------------
         *   P R I V A T E     V A R I A B L E S 
         * ---------------------------------------*/


        /*---------------------------------
         *   P U B L I C   M E T H O D S 
         * -------------------------------*/
        string path_exe;
        string temp_settings_file;
        string temp_settings_dir;
        string Options_File;
        StreamWriter sw;
        StreamReader sr;

/*----------------------------------------------------------
 * Function     : OptionsFile
 * Description  : Constructor
 * Parameters   : file_name is the name of the file to use
 * Return       : none
 * --------------------------------------------------------*/
    public OptionsFile(string settings)
    {
        if (!File.Exists(settings))
        {
            if (!Directory.Exists(Path.GetDirectoryName(settings)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(settings));
            }
            File.Create(settings).Close();
        }
        path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
        Options_File = settings; 
    }

/*----------------------------------------------------------
 * Function     : GetKey
 * Description  : gets the value of the key.
 * Parameters   : key
 * Return       : value of the key if key exist, null if not exist
 * --------------------------------------------------------*/
    public string GetKey(string key)
    {

      //  string value_of_each_key;
        string key_of_each_line;
        string line;
        int index;
        string key_value;
        key_value = null;

        sr = new StreamReader(Options_File);
        while (null != (line = sr.ReadLine()))
        {


            index = line.IndexOf("=");


           //    value_of_each_key = line.Substring(index+1);



            if (index &gt;= 1)
            {
                key_of_each_line = line.Substring(0, index);
                if (key_of_each_line == key)
                {
                    key_value = line.Substring(key.Length + 1);
                }

            }
            else
            {
            }


        }
        sr.Close();
        return key_value;
    }


/*----------------------------------------------------------
 * Function     : SetKey
 * Description  : sets a value to the specified key
 * Parameters   : key and a value
 * Return       : none
 * --------------------------------------------------------*/
    public void SetKey(string key , string value)
    {
        bool key_was_found_inside_the_loop;
        string value_of_each_key;
        string key_of_each_line ;
        string line;
        int index;
        key_was_found_inside_the_loop = false;

        temp_settings_file = "\\temp_settings_file.txt";
        temp_settings_dir = path_exe + @"\temp_settings";
        if (!Directory.Exists(temp_settings_dir))
        {
            Directory.CreateDirectory(temp_settings_dir);
        }

        sw = new StreamWriter(temp_settings_dir+temp_settings_file);
        sr = new StreamReader(Options_File);
        while (null != (line = sr.ReadLine()))
        {

            index = line.IndexOf("=");
            key_of_each_line = line.Substring(0, index);
            value_of_each_key = line.Substring( index + 1);
         //   key_value = line.Substring(0,value.Length);
            if (key_of_each_line == key)
            {
                sw.WriteLine(key + " = " + value);
                key_was_found_inside_the_loop = true;

            }
            else
            {
                sw.WriteLine(key_of_each_line+"="+value_of_each_key);
            }

        }

        if (!key_was_found_inside_the_loop)
        {
           sw.WriteLine(key + "=" + value);
        }
        sr.Close();
        sw.Close();
        File.Delete(Options_File);
        File.Move(temp_settings_dir + temp_settings_file, Options_File);
        return;

    }



    public List&lt;float&gt; GetListFloatKey(string keys)
    {
        List&lt;float&gt; result = new List&lt;float&gt;();
        string s = GetKey(keys);
        if (s != null)
        {
            string[] items = s.Split(new char[] { ',' });
            float f;
            foreach (string item in items)
            {
                if (float.TryParse(item, out f))
                    result.Add(f);
            }
            return result;
        }
        else
        {
            return result;
        }
    }


    public void SetListFloatKey(string key, List&lt;float&gt; Values)
    {
        StringBuilder sb = new StringBuilder();
        foreach (float value in Values)
        {
            sb.AppendFormat(",{0}", value);
        }
        if (Values.Count == 0)
        {
        }
        else
        {
            SetKey(key, sb.ToString().Substring(1));
        }
    }
</code></pre>

<p>Not sure whats wrong here with the numbers.</p>
