问题描述
float mag = ComputeDistance(Counter - 1,Counter - 2);
richTextBox2.Text + =\ n物体与Radar的距离=+ mag .ToString()+\ tObject Degree in Degree =+ ObjectAngle;
i想在列表中保存mag和ObjectAngle以便我可以使用它随时随地。
以上数据是每2秒使用一次计时器生成的。
我尝试过:
float mag = ComputeDistance(Counter - 1, Counter - 2);
richTextBox2.Text += "\n Object Distance from Radar=" + mag.ToString()+"\tObject Location in Degree=" +ObjectAngle;
i want to save "mag" and "ObjectAngle" in List so that i can use it whenever i want.
Above data is generating using timer every 2 second.
What I have tried:
List<dataanalyse> ObjectData = new List<dataanalyse>();
struct DataAnalyse
{
public float Avgmag;
public float AvgmagAngle;
}
Public saveData()
{
DataAnalyse da=new DataAnalyse()
da.Avgmag=mag;
da.AvgmagAngle=ObjectAngle;
}
推荐答案
public saveData(float mag, float objAngle)
{
DataAnalyse da=new DataAnalyse();
da.Avgmag=mag;
da.AvgmagAngle=objAngle;
ObjectData.Add(da);
}
您还需要在ObjectData声明中正确获取案例 - C#区分大小写,因此dataanalyse与DataAnalyse
You'll need to get the cases right on the ObjectData declaration as well - C# is case sensitive, so "dataanalyse" is not the same as "DataAnalyse"
这篇关于如何将计时器生成的数据保存到列表中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!