Another “Object does not contain a definition for X”

爱⌒轻易说出口 提交于 2019-12-23 05:41:20

问题


I saw a lot of topics with the problem:

"Object does not contain a definition for X and no extension method X accepting a first argument of type Object"

But none of them had the solution to my problem.

Situation: I want to save 3 series of DataPoints. Therefor i made a List that holds the series:

List<OxyPlot.Series.DataPointSeries> filesToBeStored;
    public OxyPlot.Series.DataPointSeries saveAnalyseBSITotal;
    public OxyPlot.Series.DataPointSeries saveAnalyseSBSI;
    public OxyPlot.Series.DataPointSeries saveAnalyseTBSI;

In the Form.cs I call the SaveFile(...):

        for (int i = 0; i < plotSBSIBandsA.Model.Series.Count; i++)
        {
            OxyPlot.Series.DataPointSeries sA = (plotSBSIBandsA.Model.Series[i] as OxyPlot.Series.DataPointSeries);
            OxyPlot.Series.DataPointSeries sB = (plotSBSIBandsB.Model.Series[i] as OxyPlot.Series.DataPointSeries);
            sB.Points.Clear();

            for (int j = 0; j < sA.Points.Count; j++)
            {
                sB.Points.Add(new OxyPlot.DataPoint(sA.Points[j].X, sA.Points[j].Y));
            }
        }
        if(saveButtonClicked)
            {this.SaveFile(sB)}

The complete Save-Class is:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;

 namespace BSIAnalyzer
 {
     class SaveFile
     {

    List<OxyPlot.Series.DataPointSeries> filesToBeStored;
    public OxyPlot.Series.DataPointSeries saveAnalyseBSITotal;
    public OxyPlot.Series.DataPointSeries saveAnalyseSBSI;
    public OxyPlot.Series.DataPointSeries saveAnalyseTBSI;

    public SaveFile(OxyPlot.Series.DataPointSeries sA)
    {
        for (int i = 0; i < sA.Points.Count; i++)
        {
            saveAnalyseBSITotal.Points.Add(new OxyPlot.DataPoint(sA.Points[i].X, sA.Points[i].Y));
        }
    }

    public SaveFile(List<OxyPlot.Series.DataPointSeries> series)
         {
             filesToBeStored.Insert(0, saveAnalyseBSITotal);
             filesToBeStored.Insert(1, saveAnalyseSBSI);
             filesToBeStored.Insert(2, saveAnalyseTBSI);

             for (int k = 0; k < series.Count; k++)
             {
                 filesToBeStored[k].Points.Add(new OxyPlot.DataPoint(series[k].Points.X, series[k].Points.Y));
             }
         }
     }
 }

In the forloop with te "k" i got the error.

来源:https://stackoverflow.com/questions/19564885/another-object-does-not-contain-a-definition-for-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!