I know there are a bunch of topics with the same question, but I am just so confused.
I want to loop through my objects properties and write the value.
But everything I have seen says to
Dim pinfo() As PropertyInfo = MyCompanies(1).GetType().GetProperties()
This creates an array with the info of the properties, but it does not store the actual value of that object.property,
The name of the property is ticker, but the value of Mycompanies(1).ticker is AMZN.
My Code:
Dim pinfo() As PropertyInfo = MyCompanies(1).GetType().GetProperties()
'Loop through Properties
For pi = 0 To pinfo.Length - 1
'I want to get the values of each property
Console.WriteLine(?)
Next pi
Note: MyCompanies(1) is just the second object in an object array, all objects are of the company class
https://msdn.microsoft.com/en-us/library/b05d59ty(v=vs.110).aspx doesnt help either. It leads me to believe that I should do:
For Each pi In pinfo
'I want to get the values of each property
Console.WriteLine(PropertyInfo.GetValue(MyCompanies(1))
Next pi
but that wont even build. Is it because I am trying to give it the object by using the position in the array?
...and outside of this loop I will have to loop through my object array, so i figured i could just replace the 1 with an i...