I have a table in SQL Server that stores x, y, z values as floats, I would like to get the values and store them in a tridimensional array.
I have been searching and I have seen people would go for adding values to a list, as we do not know how many items we could get, like:
List<int> list = new List<int>();
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
list.Add(reader.GetInt32(0));
}
}
return list.ToArray();
However I do not know if it is possible to read table and get and store elements at once
I was trying to get three lists like this:
List<double> xValuesList = (from IDataRecord r in dataReader
select (double)r["xVal"]
).ToList();
List<double> yValuesList = (from IDataRecord r in dataReader
select (double)r["yVal"]
).ToList();
List<double> zValuesList = (from IDataRecord r in dataReader
select (double)r["zVal"]
).ToList();
and then loop and get a tridimensional array from all these 3 lists..
But I think using a struct or something would be better, but I do not know how to do it.