Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Public Class Demo
Private m_field As String = "String A"
Public Field As String = "String B"
Public Const FieldC As String = "String C"
End Class
Module Module1
Sub Main()
Dim d As New Demo()
Dim myType As Type = GetType(Demo)
Dim fiPrivate As FieldInfo = myType.GetField("m_field",BindingFlags.NonPublic Or BindingFlags.Instance)
DisplayField(d, fiPrivate)
End Sub
Sub DisplayField(ByVal obj As Object, ByVal f As FieldInfo)
Console.WriteLine("{0} = ""{1}""; attributes: {2}",f.Name, f.GetValue(obj), f.Attributes)
End Sub
End Module