Hi all
Is there any possible way to access the field - str in the Class Program and the variable num - in the main function?
class Program
{
string str = "This is a string";
static void Main(string[] args)
{
int num = 100;
Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
var timer = new System.Timers.Timer(10000);
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Start();
for (int i = 0; i < 20; i++)
{
Debug.WriteLine(Thread.CurrentThread.ManagedThreadId + " " + "current I is " + i.ToString());
Thread.Sleep(1000);
}
Console.ReadLine();
}
static void timer_Elapsed(object sender, ElapsedEventArgs e)
{
Debug.WriteLine(str);
Debug.WriteLine(num);
Debug.WriteLine(Thread.CurrentThread.ManagedThreadId + " current is timer");
//throw new NotImplementedException();
}
}
Best Regards,