473,408 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Access to base class fields

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

Nov 17 '05 #1
3 1245
foreach( ListViewItem thisItem in yourListView.SelectedItems )
{
// Your code using
//((Person)thisItem.Tag).SSID
}

Brendan

"Andrea" wrote:
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

Nov 17 '05 #2
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 .

Nov 17 '05 #3
Ahh, you will then need to typecast with the fully resolved name of the
class, rather than just the short name.

Brendan

"Andrea" wrote:
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 .

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paul | last post by:
In real life situation, do we ever come across a situation where we would need two base objects in an object. A snippet is worth 1000 words (: so... class Base { }; class Derived1:public Base...
3
by: J E E | last post by:
Hi! Is it possible to access fields in a derived class using reflection? Code below works fine when I access it as a private member in the Page class, but not when accessing base class member...
3
by: J.J. Feminella | last post by:
(Please disregard the previous message; I accidentally sent it before it was completed.) I have source code similar to the following. public class Vehicle { protected string dataV; // ......
2
by: Lars-Erik Aabech | last post by:
Hi! I've got a small challenge with my class library. I've got an abstract base class with some protected fields. It has two derived classes, and it should be possible to cast these classes to...
5
by: josephrthomas | last post by:
hi.. i am using ASP.NET with VB.NET to connect to a MS Access database... can someone pls tell me how do i make the sql statement to insert a new record into the existing table pls?? also...
3
by: Jordan | last post by:
Suppose I have a system that keeps track of 5 different types of "People". My intent is to have a base Person class, then 5 derived classes for each of the specific person types (e.g., Patient,...
5
by: sherifffruitfly | last post by:
Hi, I'm just learning cpp, and the exercise I'm working on is basically as follows: 1) Create a struct type with 4 members (char, char, char, int). 2) Create an array of, say 3 instances of...
0
by: Edward Diener | last post by:
I have a base class derived from System.Web.UI.Page, and derived classes derived from the base class. The base class has protected HTML hidden fields in it, and the derived class's aspx page has...
0
by: pedz | last post by:
I am trying to write a set of classes, probably template classes, to allow "pretty" and safe access to low level machine words. The syntax I would like to end up with is something like: foo =...
6
by: MattWilson.6185 | last post by:
Hi, I'm trying to find out if something is possible, I have a few diffrent lists that I add objects to and I would like to be able to have a wrapper class that won't affect the internal object, for...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.