Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将一组数字添加到列表中的特定索引<;浮动>;?_C# - Fatal编程技术网

C# 如何将一组数字添加到列表中的特定索引<;浮动>;?

C# 如何将一组数字添加到列表中的特定索引<;浮动>;?,c#,C#,这是woc WireObjectCoordinations类的代码: Frame_X_1 =323,332,322,332 Frame_Y_1 =206,212,218,203 Frame_X_2 =323,332,318,332 Frame_Y_2 =206,212,269,203 Frame_X_3 =323,332,318,332 Frame_Y_3 =206,212,269,203 Frame_X_4 =323,332,318,332 Frame_Y_4 =206,212,269,203

这是woc WireObjectCoordinations类的代码:

Frame_X_1 =323,332,322,332
Frame_Y_1 =206,212,218,203
Frame_X_2 =323,332,318,332
Frame_Y_2 =206,212,269,203
Frame_X_3 =323,332,318,332
Frame_Y_3 =206,212,269,203
Frame_X_4 =323,332,318,332
Frame_Y_4 =206,212,269,203
Frame_X_5 =323,332,318,332
Frame_Y_5 =206,212,269,203
Frame_X_6 =323,332,318,332
Frame_Y_6 =206,212,269,203
Frame_X_7 =323,332,318,332
Frame_Y_7 =206,212,269,203
Frame_X_8 =323,332,318,332
Frame_Y_8 =206,212,269,203
Number Of Frames X=4
Number Of Frames Y=4
我现在添加了两张WOC和Point_X和Point_Y的图像:


http://imageshack.us/photo/my-images/23/imag0648me.jpg/

听起来您想使用
列表。或者,如果您的浮动集是固定的,您可能会使用
列表

请在设置代码格式方面投入更多精力。现在很难阅读,压痕遍及整个地方。在旁边的注释中:你可能想考虑使用<代码>转换。ToSingle(Twitter)<代码>而不是<代码>(浮点)转换。ToDouble(Twitter)< /Cord>什么是对帧进行分组的规则?另外,你确定你不想用“i=0”启动你的for循环吗?当前,您正在跳过第一帧。发布声明
wo1
的代码,如果没有此信息,您的问题将无法回答。我尝试了:List test=new List(floatStrings.Select(tempStr=>(float)Convert.ToDouble(tempStr)).ToList();但这并没有起作用。你能告诉我你在我的密码里是什么意思吗?等等!!我犯了一点小错误。我需要在点X的woc索引[0]中,我将在点X的每个索引中,如[0]332[1]333[2]444[3]443中,有帧X的编号,然后在点X的woc索引[1]中,在[1]12的索引[0]11中,等等……@user1526380:这背后的想法是,您将
点X
放入
列表中。然后你可以做点添加(测试)
。从本质上讲,Point_X必须是一种能够保存所需数据的类型。目前,它似乎只是一个列表,CIH不会这样做,因此您可以将其类型更改为更合适的类型。@user1526380:我想您可能需要使用此woc对象结构的详细信息更新您的问题。。。目前它没有任何明显的索引…更新了我的问题,还为两张图片添加了两个链接,以显示它是怎样的。
Frame_X_1 =323,332,322,332
Frame_Y_1 =206,212,218,203
Frame_X_2 =323,332,318,332
Frame_Y_2 =206,212,269,203
Frame_X_3 =323,332,318,332
Frame_Y_3 =206,212,269,203
Frame_X_4 =323,332,318,332
Frame_Y_4 =206,212,269,203
Frame_X_5 =323,332,318,332
Frame_Y_5 =206,212,269,203
Frame_X_6 =323,332,318,332
Frame_Y_6 =206,212,269,203
Frame_X_7 =323,332,318,332
Frame_Y_7 =206,212,269,203
Frame_X_8 =323,332,318,332
Frame_Y_8 =206,212,269,203
Number Of Frames X=4
Number Of Frames Y=4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AnimationEditor
{
    class WireObjectCoordinates
    {
        public List<float> Point_X = new List<float>();
        public List<float> Point_Y = new List<float>();

        public WireObjectCoordinates()
        {
        }

        public WireObjectCoordinates(WireObjectCoordinates w)
        {
            Point_X.AddRange(w.Point_X);
            Point_Y.AddRange(w.Point_Y);
        }

        public void Set(WireObjectCoordinates w)
        {
            for (int i = 0; i < Point_X.Count; i++)
            {
                Point_X[i] = w.Point_X[i];
                Point_Y[i] = w.Point_Y[i];
            }
        }
    }
}
/*----------------------------------------------------------
 * 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;
    }