user1118700
user1118700

Reputation: 67

convertion of datatable/dataset to a given array

I am referring one tutorial which is in php.I am converting in into C#.The thing is that they have used

my query in this

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)
      )
  )
);

the result after executing in the postgresql is

"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)))";

Now After this my php do the conversion of this is array(which converts the given system datatable into array)

$arr = pg_fetch_array($res);

Now i want to write similar function which php do? But unable to convert correctly

my function look like this

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;

    }

somebody Please help me. Thanks in Advance.

Upvotes: 0

Views: 1539

Answers (1)

tstuts
tstuts

Reputation: 494

The System.Data.DataRow class has an ItemArray property that returns the row's values in an array (of type object)

So, maybe the following example will help you get where you're trying to go:

foreach (DataRow row in Dt.Rows)
{
    object[] values = row.ItemArray;
}

Upvotes: 1

Related Questions