Csharp/C#教程:另一个“对象不包含X的定义”分享


另一个“对象不包含X的定义”

我看到了很多关于这个问题的主题:

“对象不包含X的定义,并且没有扩展方法X接受Object类型的第一个参数”

但他们都没有解决我的问题。

情况:我想保存3个系列的DataPoints。 因此我制作了一个包含该系列的列表:

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

在Form.cs中,我调用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)} 

完整的Save-Class是:

  using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BSIAnalyzer { class SaveFile { List 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 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)); } } } } 

在te“k”的forloop中我得到了错误。

上述就是C#学习教程:另一个“对象不包含X的定义”分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/991569.html

(0)
上一篇 2021年12月23日
下一篇 2021年12月23日

精彩推荐