-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: SitaramanM
Message 2 in Discussion
Hi You can use the GetType function. Remember that static variables are those
variables which are per-type. this means that while normal member variables belong to
the object instance, the shared/static variables belong to type. So this means
that if you pass the object as parameter to GetValue for instance variables, from the
precious paragraph,you can pass the type of the class for static/shared variables.
here is a sample Imports System.Reflection Module Module1 Sub Main()
fnSetStaticValueDirectly()
Console.WriteLine(Class1.i) ' will print 10
fnSetStaticValueThroughReflection()
Console.WriteLine(Class1.i) ' will print 20 Console.ReadLine()
End Sub Public Sub fnSetStaticValueDirectly()
Class1.i = 10
End Sub Public Sub fnSetStaticValueThroughReflection()
Dim l_objType As Type
Dim l_objFieldInfo As FieldInfo
l_objFieldInfo = GetType(Class1).GetField("i", BindingFlags.Static Or
BindingFlags.GetField Or BindingFlags.NonPublic Or BindingFlags.Public)
l_objFieldInfo.SetValue(GetType(Class1), 20)
End Sub End Module
Class Class1 Public Shared i As Integer End Class
hth regards, sr
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]