我是否可以使用c#中的简单循环将多个数组放置在一个图表上,而不是一次只放置一个系列?

我是否可以使用c#中的简单循环将多个数组放置在一个图表上,而不是一次只放置一个系列?,c#,arrays,foreach,charts,C#,Arrays,Foreach,Charts,我有一个包含大量数组的代码,但假设在这个示例中只有五个数组:aa、bb、cc、dd和ee,它们已经赋值了。我想将这些数组放在一个图表上(以比较值)。我知道我可以一次做一个,但我想知道是否有某种方法可以用循环来做,浮动数组会在每次传递时提取原始数组的值,并将其值发送到图表上。大概是这样的: double[] aa = new double[100]; double[] bb = new double[100]; double[] cc = new d

我有一个包含大量数组的代码,但假设在这个示例中只有五个数组:aa、bb、cc、dd和ee,它们已经赋值了。我想将这些数组放在一个图表上(以比较值)。我知道我可以一次做一个,但我想知道是否有某种方法可以用循环来做,浮动数组会在每次传递时提取原始数组的值,并将其值发送到图表上。大概是这样的:

        double[] aa = new double[100];
        double[] bb = new double[100];
        double[] cc = new double[100];
        double[] dd = new double[100];
        double[] ee = new double[100];

        double[] floatingArray = new double[100];

        // values to the first five arrays are assigned here...

        foreach (var series in chart1.Series)
        {
            /*
            a loop (or loops) where on each run floatingArray picks up values from
            the original five arrays in turns, and then sends them down to the
            following line of code:
            */
            series.Points.AddXY(someGenericValue.ToString(),floatingArray);
        }
    var arrayData = new[]
    {
        new double[100],
        new double[100],
        new double[100],
        new double[100],
        new double[100]
    };

    // values to the first five arrays are assigned here...
    arrayData [0][0] = 1; // <- first element of the first array
    arrayData [0][1] = 2; // <- second element of the first array
    arrayData [1][0] = 1; // <- first element of the second array
    arrayData [3][51] = 2; // <- fifty-second element of the fourth array

    foreach (var series in chart1.Series)
    {
        foreach (var arrayItem in arrayData)
        {
            series.Points.AddXY(someGenericValue.ToString(), arrayItem);
        }
    }

如果您没有投资于“浮动阵列”的想法,您可以这样做:

        double[] aa = new double[100];
        double[] bb = new double[100];
        double[] cc = new double[100];
        double[] dd = new double[100];
        double[] ee = new double[100];

        double[] floatingArray = new double[100];

        // values to the first five arrays are assigned here...

        foreach (var series in chart1.Series)
        {
            /*
            a loop (or loops) where on each run floatingArray picks up values from
            the original five arrays in turns, and then sends them down to the
            following line of code:
            */
            series.Points.AddXY(someGenericValue.ToString(),floatingArray);
        }
    var arrayData = new[]
    {
        new double[100],
        new double[100],
        new double[100],
        new double[100],
        new double[100]
    };

    // values to the first five arrays are assigned here...
    arrayData [0][0] = 1; // <- first element of the first array
    arrayData [0][1] = 2; // <- second element of the first array
    arrayData [1][0] = 1; // <- first element of the second array
    arrayData [3][51] = 2; // <- fifty-second element of the fourth array

    foreach (var series in chart1.Series)
    {
        foreach (var arrayItem in arrayData)
        {
            series.Points.AddXY(someGenericValue.ToString(), arrayItem);
        }
    }
var arrayData=new[]
{
新双[100],
新双[100],
新双[100],
新双[100],
新双[100]
};
//前五个数组的值在此处指定。。。

arrayData[0][0]=1;//嗯,很有趣,看起来很像我想要的东西,但是我如何通过var arrayData初始化不同数组的值呢?这不是我以前遇到过的…
arrayData
是一个数组数组,因此您可以通过依次访问每个数组来填充它-我用一些示例更新了我的答案:)谢谢,这很有帮助!不用担心,很乐意帮忙!:)