jlaroussi

Converting array to a table

Discussion created by jlaroussi on Mar 9, 2011
Latest reply on Mar 21, 2011 by jlaroussi
I am preparing a report based on selected records from a feature class. Using Arc Objects I select values from each record/row in fields street, fromLeft, toLeft, fromRight, toRight and concatenate it into one line for each one record/row. Final selection is exported to pdf file. Because streets names have a different length my output looks messy. I wish I can build a table, where each column will store one field. I also would like to be able sort my records by street name before it produces final output. Any ideas how to change this:

IFeatureCursor pedCursor = featureClassPed.Search(queryAPedFilter, true);
IFeature pedFeature = pedCursor.NextFeature();
while (pedFeature != null)
{
    //getting the values for each field and saving it into variables
    IFields pedAFields = featureClassPed.Fields;
    int distanceAField = pedAFields.FindField("S_00000");
    int streetAField = pedAFields.FindField("Street");
    int fromALeftField = pedAFields.FindField("FromLeft");
    int toALeftField = pedAFields.FindField("ToLeft");
    int fromARightField = pedAFields.FindField("FromRight");
    int toARightField = pedAFields.FindField("ToRight");
    //saving variables
    string streetAValue = pedFeature.get_Value(streetAField).ToString();
    string fromALeftValue = pedFeature.get_Value(fromALeftField).ToString();
    string toALeftValue = pedFeature.get_Value(toALeftField).ToString();
    string fromARightValue = pedFeature.get_Value(fromARightField).ToString();
    string toARightValue = pedFeature.get_Value(toARightField).ToString();
    //building an array
    string[] pedA = new string[9] { streetAValue, "      ", fromALeftValue, "      ",  toALeftValue, "      ", fromARightValue, "      ", toARightValue };
              
    outputA += string.Join(" ", pedA) + "\r\n";
               
    pedFeature = pedCursor.NextFeature();
}

into a table?

Here is an example of output:

LAFAYETTE ST 33 51 34 54
CRAIG AV 538 552 537 549
FINLAY ST 1 19 2 20
AMBOY RD 7660 7682 7657 7679
BENTLEY ST 131 177 128 180

Which I rather see as:

AMBOY RD 7660 7682 7657 7679
BENTLEY ST 131 177 128 180
CRAIG AV 538 552 537 549
FINLAY ST 1 19 2 20
LAFAYETTE ST 33 51 34 54

Outcomes