请高手解释这个C#程序,其中ServiceBase是windows服务基类,SmsService是

请高手解释这个C#程序,其中ServiceBase是windows服务基类,SmsService是

ServiceBase的子类。

static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new SmsService()
};
ServiceBase.Run(ServicesToRun);
}

满意答案

采纳率:53%9级 2014.04.05
ServiceBase[] ServicesToRun; // 初始化父类 数组
ServicesToRun = new ServiceBase[]{new SmsService()}; // 实例化该数组,数组中仅有一个子类 实例元素
ServiceBase.Run(ServicesToRun); //调用父类Run方法,以子类为 参数,功能是运行子类实例

猜你喜欢

转载自www.cnblogs.com/bwdblogs/p/11713304.html