I have a database that determines the X, Y coordinate pair table in the specific data element.
coordinates {int x, int y, int value}
How do I add these coordinates to a table? If there are spaces in the database (marked by -
):
Y 0 1 ------- 0 | 4 6 7 x 1 9 - 7 2 6 3 5
How do I manage this in linq?
LINQ is generally good for working with structured (one dimensional) data such as database or XML files But I do not think that when you need to create a two-dimensional data structure, it will help you.
If you want to load the data in the 2D array, it may be straightforward to write it. The way (using the max
extension method) is not much better to get from LINQ Value):
int [,] value = new int [coords.max (c => cx) + 1, coords.max (c => cY) + 1]; Forresh (different C in the corode) value [cx, ci] = c. well;
If you want to do it in another way - to generate coordinates from the 2D array, then you can generate an index of LINQ's Enumerable.Range
There are 2D arrays and where
to select some real values elements:
var in Konqueror = i in enumerable.Range (0, coords.GetLength ( 0)) nominated in Jammu. Category (0, coords.GetLength (1)) v = Corners [i, j] Where v! = '-' Select new {X = I, Y = J, value = Int32.Parse (v)}
Comments
Post a Comment