程序中有十几个类 每个类中都要用到webserver中的 [WebMethod]方法
难道每个都要这样new下? localhost.WebTest test = new localhost.WebTest();
;
有什么更好的办法?
程序中有十几个类 每个类中都要用到webserver中的 [WebMethod]方法
难道每个都要这样new下? localhost.WebTest test = new localhost.WebTest();
;
有什么更好的办法?
可以用工厂模式
public static WebServiceFactory
{
public static localhost.WebTest Instance
{
get { return new localhost.WebTest(); }
}
}
使用
WebServiceFactory.Instance.xxx方法