Reflection - GetValue in a Structure

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..
 
B

Branco Medeiros

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.
 

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