Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:33:51+00:00 2026-06-07T23:33:51+00:00

In the for loop i did: string[] xFrames = new string[wocl.Count]; string[] yFrames =

  • 0

In the for loop i did:

string[] xFrames = new string[wocl.Count];
            string[] yFrames = new string[wocl.Count];
            List<float> Xframes = new List<float>(wocl.Count);
            List<float> Yframes = new List<float>(wocl.Count);
            for (int i = 0; i < 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 < 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);

            }

The result in the text file is:

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

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

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.

The setting_file im using is connected to the OptionsFile class:

/*----------------------------------------------------------------
 * 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 >= 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<float> GetListFloatKey(string keys)
    {
        List<float> result = new List<float>();
        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<float> 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));
        }
    }

Not sure whats wrong here with the numbers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:33:54+00:00Added an answer on June 7, 2026 at 11:33 pm

    You use a double loop in this way:

    string[] xFrames = new string[wocl.Count];
    string[] yFrames = new string[wocl.Count];
    
    for (int i = 0; i < wocl.Count; i++)
    {
       xFrames[i] = string.Format("Frame_X_{0} ", i + 1);
       yFrames[i] = string.Format("Frame_Y_{0} ", i + 1);
    
       for(int j =0; j < wocl[i].Length; j++)
       {
           xFrames[i] += string.Format("{0},", wocl[i].Point_X[j]);
           yFrames[i] += string.Format("{0},", wocl[i].Point_Y[j]);
       }
    
       xFrames[i].Trim(",".ToCharArray());
       yFrames[i].Trim(",".ToCharArray());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With n=5 and k=3 the following loop will do it List<String> l=new ArrayList<String>(); l.add(A);l.add(B);l.add(C);l.add(D);l.add(E);
I have a loop where i create some string value based on certain conditions.
To prevent the infinite loop I did something as ugly as this... @Override protected
The output is an infinite loop of cannot open the file. what did I
I was using a foreach loop to go through a list of data to
I have a string that looks like: key1/value1/key2/value2/ and so on I did an
I am using a for loop to iterate through a list of arrays that
So basically: #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> int main(void){ //test strrev
I have a list of websites in a string and I was doing a
A coworker used a for loop to iterate a List in some C# code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.