-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: SitaramanM
Message 3 in Discussion
Hi I had posted the vb code in my previous post. If you want the C# equivalent,
here it is using System;
using System.Reflection;
namespace ConsoleApplication9
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
fnSetStaticValueDirectly();
Console.WriteLine(Class2.i); fnSetStaticValueThroughReflection();
Console.WriteLine(Class2.i); Console.ReadLine(); }
public static void fnSetStaticValueThroughReflection()
{
Type l_objType;
FieldInfo l_objFieldInfo;
l_objType=typeof(Class2);
l_objFieldInfo=l_objType.GetField("i", BindingFlags.Static | BindingFlags.GetField
| BindingFlags.NonPublic | BindingFlags.Public);
l_objFieldInfo.SetValue(typeof(Class2), 20);
} public static void fnSetStaticValueDirectly()
{
Class2.i = 10;
}
}
class Class2
{
public static int i; }
}
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]