BindingFlags.Public Or BindingFlags.Instance
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 fiPublic As FieldInfo = myType.GetField("Field",BindingFlags.Public Or BindingFlags.Instance)
DisplayField(d, fiPublic)
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
Related examples in the same category