FieldInfo Class represents the attributes of a field and provides access to field metadata. : FieldInfo « Reflection « VB.Net






FieldInfo Class represents the attributes of a field and provides access to field metadata.

 

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class FieldInfoClass
    Public myField1 As Integer = 0
    Protected myField2 As String = Nothing

    Public Shared Sub Main()
        Dim myFieldInfo() As FieldInfo
        Dim myType As Type = GetType(FieldInfoClass)
        myFieldInfo = myType.GetFields(BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.Public)
        Dim i As Integer
        For i = 0 To myFieldInfo.Length - 1
            Console.WriteLine(ControlChars.NewLine + "Name            : {0}", myFieldInfo(i).Name)
            Console.WriteLine("Declaring Type  : {0}", myFieldInfo(i).DeclaringType)
            Console.WriteLine("IsPublic        : {0}", myFieldInfo(i).IsPublic)
            Console.WriteLine("MemberType      : {0}", myFieldInfo(i).MemberType)
            Console.WriteLine("FieldType       : {0}", myFieldInfo(i).FieldType)
            Console.WriteLine("IsFamily        : {0}", myFieldInfo(i).IsFamily)
        Next i
    End Sub
End Class

   
  








Related examples in the same category

1.FieldInfo.Attributes Property gets the attributes associated with this field.
2.FieldInfo.FieldHandle Property gets a RuntimeFieldHandle
3.FieldInfo.FieldType Property gets the type of this field object.
4.FieldInfo.GetFieldFromHandle gets a FieldInfo for the field represented by the specified handle.
5.FieldInfo.GetFieldFromHandle
6.FieldInfo.GetValue Method returns the value of a field supported by a given object.
7.FieldInfo Get Value
8.FieldInfo.IsAssembly
9.FieldInfo.IsInitOnly Property tells whether the field can only be set in the body of the constructor.
10.FieldInfo.IsNotSerialized
11.FieldInfo.IsPinvokeImpl
12.FieldInfo.IsPrivate
13.FieldInfo.IsPublic
14.FieldInfo.IsSpecialName tells whether the SpecialName attribute is set in the FieldAttributes enumerator.
15.FieldInfo.IsStatic
16.FieldInfo.MemberType
17.FieldInfo.SetValue sets the value of the field supported by the given object.