Reflection - GetValue in a Structure

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hello,

i have this structure..

Public Structure MyStructure
a as boolean
b as boolean
c as boolean
....
end structure

Dim Infos() As FieldInfo
Dim fi As FieldInfo
mInfos = GetType(MyStructure).GetFields

for each fi in Infos
msgbox fi.name
next

I Would "VALUE" for this Field..
 
John said:
Hello,

i have this structure..

Public Structure MyStructure
a as boolean
b as boolean
c as boolean
....
end structure

Dim Infos() As FieldInfo
Dim fi As FieldInfo
mInfos = GetType(MyStructure).GetFields

for each fi in Infos
msgbox fi.name
next

I Would "VALUE" for this Field..

You must provide an 'instance' of your structure to the FieldInfo
class:

Dim X As MyStructure
'...
for each fi in Infos

Dim Value As Object = fi.GetValue(X)
MsgBox fi.Name & "=" & Value.ToString

Regards,

Branco.
 
Back
Top