user175084
user175084

Reputation: 4630

get values of data structure from arraylist

I have an arraylist which has data structures in it.

I am having problems trying to figure out how to get those values back and show them in a table..

Thanks this is my structure..

  public BackupSpecEntry(string Path, string InclExcl, byte InclExclFlags, bool IndexContents,
        int ServerBackupSpecId, int Freq, int Retention)
    {
        path = Path;
        inclExcl = InclExcl;
        inclExclFlags = InclExclFlags;
        indexContents = IndexContents;
        serverBackupSpecId = ServerBackupSpecId;
        freq = Freq;
        retention = Retention;
    }

Upvotes: 0

Views: 429

Answers (3)

cdm9002
cdm9002

Reputation: 1960

With an ArrayList you need to cast them,

ArrayList list = new ArrayLIst();

: your code

BackupSpecEntry entry = (BackupSpecEntry)list[0];

However, with generics with C# you can create a template list:

List<BackupSpecEntry> list = new List<BackupSpecEntry>();

: your fill list code

BackupSpecEntry entry = list[0];

Upvotes: 2

monksy
monksy

Reputation: 14234

I assume by Table and by the Asp.net attribute that you mean a DataGrid, GridView, or DetailsView. Is this correct. Assuming that it is: read up on Data binding and custom objects. There is a lot of information about this subject on the internet if you look for it.

Upvotes: 0

David
David

Reputation: 34563

An ArrayList isn't strongly typed so whenever you pull out an item, you have to cast it back to your custom object type. Then you should be able to access it's properties.

Upvotes: 0

Related Questions