Access to base class fields

  • Thread starter Thread starter Andrea
  • Start date Start date
A

Andrea

This is my question. I have a listview. In every item of listview in
the Tag property i have an object. These objects are all instance of
different subclasses of the person class. I wish to use SSID field
defined in the person base class to start another job. what is the most
elegant way to make this?

I can test the object type and then use appropriate subclass property
to get SSID. is there more simple method?

Thanks
 
foreach( ListViewItem thisItem in yourListView.SelectedItems )
{
// Your code using
//((Person)thisItem.Tag).SSID
}

Brendan
 
Thanks. That was my first try. I had "Cast not valid error" because i
have 2 classes named Person in this project. I have appreciate your
help .
 
Ahh, you will then need to typecast with the fully resolved name of the
class, rather than just the short name.

Brendan
 
Back
Top