How Create a List of PointPairLists?

86 Views Asked by At

I have some PointPairLists and I want to Add them to a List; but I face with Exception index out of range for : AllPhiLines[0].Add(Quartz[0]);

I tried below code:

        PointPairList Quartz = new PointPairList(7000);
        PointPairList Calcite = new PointPairList(7000);
        PointPairList Dolomite = new PointPairList(7000);
        double[] XQuartz = { -2.05E+00, -1.05E+00, -4.01E-01, 4.25E-01, 1.31E+00, 2.08E+00 };
        double[] YQuartz = {2.64E+00 ,2.62E+00 ,2.61E+00 ,2.59E+00 ,2.57E+00 ,2.55E+00 };
        double[] XCalcite = {-2.83E-01 ,7.19E-01 ,1.90E+00 ,2.96E+00 ,4.02E+00 ,5.02E+00 ,6.03E+00 ,7.09E+00 };
        double[] YCalcite = {2.71E+00 ,2.69E+00 ,2.68E+00 ,2.66E+00 ,2.64E+00 ,2.62E+00 ,2.60E+00 ,2.58E+00 };
        double[] XDolomite = {1.31E+00 ,2.67E+00 ,4.02E+00 ,5.32E+00 ,6.62E+00 ,7.79E+00 ,9.03E+00 };
        double[] YDolomite = {2.88E+00 ,2.86E+00 ,2.84E+00 ,2.82E+00 ,2.80E+00 ,2.78E+00 ,2.76E+00 };
        for (int i=0; i<6; i++)
        {
            Quartz.Add(XQuartz[i], YQuartz[i]);
        }
        for (int i=0; i<8; i++)
        {
            Calcite.Add(XCalcite[i], YCalcite[i]);
        }
        for (int i=0; i<7; i++)
        {
            Dolomite.Add(XDolomite[i], YDolomite[i]);
        }
        List<PointPairList> AllPhiLines = new List<PointPairList>();
        AllPhiLines[0].Add(Quartz[0]);
        AllPhiLines[0].Add(Calcite[0]);
        AllPhiLines[0].Add(Dolomite[0]);
        LineItem AllPhiLinesCurve = pane1.AddCurve("Phi", AllPhiLines[0], Color.Gray, SymbolType.None)

hope anyone help me to fix it

1

There are 1 best solutions below

0
MarTim On BEST ANSWER

AllPhiLines does not contain any values yet, so you cannot address item 0. After creating AllPhiLines you first have to add an item to it, like

AllPhiLines.Add(new PointPairList(7000));