brdrok
asked on
Examining properties and their values during run time
Hi,
I'd like to examing the properties and their values during run time. For example, let's say I have the two following classes:
public class Student
{
private string m_name
public string Name
{
get { return m_name; } set { m_name = value; }
}
}
public class Building
{
private string m_location;
public string Location
{
get { return m_location; } set { m_location = value; }
}
I would like to create a some sort of a procedure, that takes a class and examines all the available properties along with their assigned values.
In the end, I would have a message that says something like the following:
Class: Person
Properties: Name Value: John Smith
Class: Building
Properties: Location Values: Ohio
hope I made sense. If not, please ask away.
thanks
I'd like to examing the properties and their values during run time. For example, let's say I have the two following classes:
public class Student
{
private string m_name
public string Name
{
get { return m_name; } set { m_name = value; }
}
}
public class Building
{
private string m_location;
public string Location
{
get { return m_location; } set { m_location = value; }
}
I would like to create a some sort of a procedure, that takes a class and examines all the available properties along with their assigned values.
In the end, I would have a message that says something like the following:
Class: Person
Properties: Name Value: John Smith
Class: Building
Properties: Location Values: Ohio
hope I made sense. If not, please ask away.
thanks
Keep in mind that if you are trying to do this for a CLASS, you can only find values of static properties, since the other properties are attached to specific OBJECTS with a class of that type.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
many thanks for your reply. it's almost 6pm and i'm brain dead. i'll try your suggestion first thing tomorrow morning. Looks promising though.
How did it go?
ASKER
heya,
in the end, we decided to scrap it altogether. However, did learn a new thing about reflection stuff. Many thanks.
in the end, we decided to scrap it altogether. However, did learn a new thing about reflection stuff. Many thanks.
Take a look at the System.Reflection namespace,and you will find the kinds of functions you will need.