我指的是php中的一个教程。我正在转换成C#。事情就是他们已经使用了
我的查询
SELECT ST_AsText(
ST_Union(
ST_Difference(
ST_Buffer(ST_GeometryFromText('POINT(0 0)', 4326), 30),
ST_Envelope(
ST_Buffer(ST_GeometryFromText('POINT(0 0)', 4326), 10)
)
),
ST_Envelope(
ST_Buffer(ST_GeometryFromText('POINT(-55 -55)', 4326), 10)
)
)
);
在postgresql中执行后的结果是
"MULTIPOLYGON(((30 0,29.4235584120969 -5.85270966048384,27.7163859753386 -11.4805029709527,24.9440883690764 -16.6671069905881,21.2132034355964 -21.2132034355964,16.6671069905881 -24.9440883690763,11.4805029709527 -27.7163859753386,5.85270966048389 -29.4235584120969,4.84662765649901e-014 -30,-5.85270966048379 -29.4235584120969,-11.4805029709526 -27.7163859753386,-16.667106990588 -24.9440883690764,-21.2132034355964 -21.2132034355965,-24.9440883690763 -16.6671069905881,-27.7163859753386 -11.4805029709528,-29.4235584120969 -5.85270966048394,-30 -9.69325531299803e-014,-29.4235584120969 5.85270966048375,-27.7163859753386 11.4805029709526,-24.9440883690764 16.667106990588,-21.2132034355965 21.2132034355963,-16.6671069905882 24.9440883690763,-11.4805029709528 27.7163859753386,-5.85270966048396 29.4235584120969,-1.12092138956216e-013 30,5.85270966048374 29.4235584120969,11.4805029709526 27.7163859753386,16.667106990588 24.9440883690764,21.2132034355964 21.2132034355965,24.9440883690763 16.6671069905881,27.7163859753386 11.4805029709528,29.4235584120969 5.85270966048391,30 0),(-10 -10,10 -10,10 10,-10 10,-10 -10)),((-65 -65,-65 -45,-45 -45,-45 -65,-65 -65)))";
现在这之后我的php做了转换,这是数组(将给定的系统数据表转换为数组)
$arr = pg_fetch_array($res);
现在我想写一些php做的类似功能? 但无法正确转换
我的功能看起来像这样
public Array FetchArray(DataTable Dt)
{
int[] array;
Array arr = new Array[];
Array converted = new Array(Dt.Rows.Count);
foreach (DataRow row in Dt.Rows)
{
arr.Add(row);//here it should convert the system DataTable into sytem array
}
return arr;
}
有人请帮帮我。
在此先感谢。
答案 0 :(得分:1)
System.Data.DataRow
类具有ItemArray
属性,该属性返回数组中的行值(类型为object
)
因此,以下示例可能会帮助您实现目标:
foreach (DataRow row in Dt.Rows)
{
object[] values = row.ItemArray;
}