请高手解释这个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方法,以子类为参数,功能是运行子类实例

posted on 2019-10-21 14:12  newlives  阅读(616)  评论(0编辑  收藏  举报