gspeedtech
Member
- Joined
- Mar 13, 2010
- Messages
- 11
- Programming Experience
- Beginner
I have a custom class named Location with multiple properties.
Example
Class = Location
Property = Street
Value = "Main St"
Property = City
Value = "AnyTown"
Property = Country
Value = "USA"
Through reflection I can get the names of each property:
Results:
p.Name = Street
p.Name = City
p.Name = Country
How can I get the value of each p.Name and return "Main St", "AnyTown" o "USA"
Example
Class = Location
Property = Street
Value = "Main St"
Property = City
Value = "AnyTown"
Property = Country
Value = "USA"
Through reflection I can get the names of each property:
VB.NET:
Public Function GetLocationValue(ByRef sLocation)
Dim sTable As New ProjectSchema.Location
sTable = sLocation
For Each p As System.Reflection.PropertyInfo In sTable.GetType().GetProperties()
If p.CanRead Then
Console.WriteLine(p.Name)
End If
Next
End Function
p.Name = Street
p.Name = City
p.Name = Country
How can I get the value of each p.Name and return "Main St", "AnyTown" o "USA"