Elliot,
Well, the way you have it, you can't, as the EventHandler delegate only
takes two parameters.
However, you can make the value text available to t by setting a field
in the class that t is on, and then use it that way.
Or, you can use an anonymous method and change t like so:
private void t(object sender, EventArgs eArgs, string text)
{
}
string text = "text";
Timer a = new Timer();
a.Interval = 10000;
a.Start();
a.Tick += delegate(object sender, EventArgs e) { t(sender, e, text); };
If you are using C# 3.0, you can use a lambda expression as well to make
this code even smaller.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Elliot" <el************@hotmail.co.ukwrote in message
news:39**********************************@microsof t.com...
How can I pass the value of variable text to t except declare text at
class level?
..........
string text = "text";
Timer a = new Timer();
a.Interval = 10000;
a.Start();
a.Tick += new EventHandler(t);
..........
private void t(object sender, EventArgs eArgs)
{
}