Using reflection to get instance name

G

Guest

(using .net 2.0)

Say you have a class structure like this:

class Address
....
end class

class Person
FirstName
LastName
MailingAddress as Address
BillingAddress as Address
end class

I'm using reflection to pull out the values at runtime, but I'm having
trouble when I dive into an address. When I'm traversing the object I know
when the type is address and I can get and set values on that instance, but I
can't figure a way to know if I'm looking at the mailing address or the
billing address. Is there a way to get the instance name of an object at
runtime? I've thought about setting a name property in the object, but
that's a bit of a hack and makes things much less reusable. Thanks in
advance.
 
B

Brian Schwartz

Also posted in microsoft.public.dotnet.general.csharp

Hi Jason,

It's fine to ask your question in multiple groups, but include all the group
names in one message, rather than posting separately to each one. This saves
people time answering your question if someone in another group has already
answered it.
 
G

Guest

Will do. Thanks for the tip.

Brian Schwartz said:
Also posted in microsoft.public.dotnet.general.csharp

Hi Jason,

It's fine to ask your question in multiple groups, but include all the group
names in one message, rather than posting separately to each one. This saves
people time answering your question if someone in another group has already
answered it.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets
 

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