问题描述
我有一个网格视图,想从其元素创建一个数组.感兴趣的列中的元素是浮点型的.
I have a grid view and want to create an array from its elements. The elements in the columns of interest are of float type.
我有此代码:
公共结构点
{
公众持股量;
公众持股;
}
....
public struct Point
{
public float lat;
public float lon;
}
....
公共点[] GetPoint()
{
int br = GridView1.Rows.Count;
Point [] Niza = new Point [br];
public Point[] GetPoint()
{
int br = GridView1.Rows.Count;
Point[] Niza = new Point[br];
foreach(GridView1.Rows中的GridViewRow行)
{
int i = 0;
foreach (GridViewRow row in GridView1.Rows)
{
int i = 0;
Niza [i] .lat = float.Parse(row.Cells [3] .Text,System.Globalization.NumberStyles.Any);
Niza [i] .lon = float.Parse(row.Cells [4] .Text,System.Globalization.NumberStyles.Any);
i ++;
Niza[i].lat = float.Parse(row.Cells[3].Text, System.Globalization.NumberStyles.Any);
Niza[i].lon = float.Parse(row.Cells[4].Text, System.Globalization.NumberStyles.Any);
i++;
}
返回Niza;
}
}
return Niza;
}
但是不行.例如,我有一个8的数组,但是数组中的元素是0.0,这是不正确的.
but it is not OK. I got an array of 8 for example, but the elements in the array are 0.0 which is not true.
有人可以帮我吗?
预先感谢.
推荐答案
这篇关于从GridView浮点型元素创建数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!