C#.NET中的事件
/*
* Created by SharpDevelop.
* User: noo
* Date: 2009-8-16
* Time: 18:13
*
* 事件
*/
using System ;
using System .Timers ;
class Test
{
static int counter=0;
static string displayString="这些字符串将会以每次显式一个字符的形式显示在窗口中。";
static void Main()
{
Timer myTimer=new Timer(100);
myTimer.Elapsed +=new ElapsedEventHandler (myWriteChar);
myTimer.Start ();
Console.ReadKey ();
}
static void myWriteChar(object sender,ElapsedEventArgs e)
{
Console.Write (displayString[counter++ % displayString.Length]);//这种写法方式应掌握
}
}
* Created by SharpDevelop.
* User: noo
* Date: 2009-8-16
* Time: 18:13
*
* 事件
*/
using System ;
using System .Timers ;
class Test
{
static int counter=0;
static string displayString="这些字符串将会以每次显式一个字符的形式显示在窗口中。";
static void Main()
{
Timer myTimer=new Timer(100);
myTimer.Elapsed +=new ElapsedEventHandler (myWriteChar);
myTimer.Start ();
Console.ReadKey ();
}
static void myWriteChar(object sender,ElapsedEventArgs e)
{
Console.Write (displayString[counter++ % displayString.Length]);//这种写法方式应掌握
}
}