Overcasting an instance of a class

N

News.microsoft.com

I have a service on which I can make a request that returns an object of
type Person (for example). I would like to add some additional properties
to this class without modifing the Person class. At first I thought
inheritance but I am receiving an instance of the Person object. I could
use a wrapper class and assign the person instance to a property in the
wrapper class but then I would have to re-write each property in the person
class to expose it in the wrapper class. Is there a way to create a new
object that over-classes (if you will) an instance of another class.



Example:

Person Class < I get an instance of this class from the service I call
FirstName
LastName

NewPerson Class < I want to add the FullName property to it
FirstName (inherted from Person)
LastName (inherted from Persion)
FullName = FirstName & LastName
 
C

Chris Dunaway

You can try writing an extender class. Kind of like the tool tip
component that you drag to a form.

Look up extender classes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top