assign a variable using reflection

Discussion in 'ASP .Net Building Controls' started by Nigel Findlater, Sep 17, 2003.

  1. Hallo,

    I am trying to assign a variable using reflection, Does
    anyone know how this is done?

    Any suggestions would be appriciated..

    Nigel...

    This is what I have so far:

    Structure TestStruct
    Dim A As Integer
    Dim B As Double
    Dim C As Double
    End Structure

    Public Test As TestStruct

    Public Sub TestSub(ByRef Row As Object)
    Dim i As Integer
    Dim fields() As FieldInfo
    fields = Row.GetType.GetFields
    For i = 0 To fields.Length - 1
    MessageBox.Show("Field = " + fields(i).Name)
    REM I would like to set element A to 1 here
    Next
    End Sub

    TestSub(Test)
    MessageBox.Show(Test.A.ToString)
     
    Nigel Findlater, Sep 17, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    8
    Views:
    53,630
    saravanavsk
    Jan 25, 2010
  2. Nmishra
    Replies:
    3
    Views:
    370
    Default User
    May 24, 2004
  3. Replies:
    18
    Views:
    7,101
    Karl Heinz Buchegger
    Jul 22, 2005
  4. Ranjan
    Replies:
    1
    Views:
    2,770
    Eliyahu Goldin
    Apr 10, 2007
  5. Jase Schick
    Replies:
    11
    Views:
    589
    Geoff
    Aug 5, 2010
Loading...

Share This Page