FieldInfo Get Value : FieldInfo « Reflection « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net » Reflection » FieldInfoScreenshots 
FieldInfo Get Value
 

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class MyClass1
    Public myFieldA As String
    Public myFieldB As String

    Public Sub New()
        myFieldA = "A public field"
        myFieldB = "Another public field"
    End Sub 'New
End Class 'MyClass1

Public Class FieldInfo_GetValue

    Public Shared Sub Main()
        Dim myInstance As New MyClass1()
        ' Get the type of MyClass1.
        Dim myType As Type = GetType(MyClass1)
        Try
            Dim myFields As FieldInfo() = myType.GetFields((BindingFlags.Public Or BindingFlags.Instance))
            Console.WriteLine(ControlChars.NewLine & "Displaying the values of the fields of {0}." & ControlChars.NewLine, myType.ToString())
            Dim As Integer
            For i = To myFields.Length - 1
                Console.WriteLine("The value of the field {0} is: {1}", myFields(i).Name, myFields(i).GetValue(myInstance))
            Next i
        Catch As Exception
            Console.WriteLine("Exception : {0}", e.Message.ToString())
        End Try
    End Sub 
End Class

   
  
Related examples in the same category
1.FieldInfo Class represents the attributes of a field and provides access to field metadata.
2.FieldInfo.Attributes Property gets the attributes associated with this field.
3.FieldInfo.FieldHandle Property gets a RuntimeFieldHandle
4.FieldInfo.FieldType Property gets the type of this field object.
5.FieldInfo.GetFieldFromHandle gets a FieldInfo for the field represented by the specified handle.
6.FieldInfo.GetFieldFromHandle
7.FieldInfo.GetValue Method returns the value of a field supported by a given object.
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.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.