Another way to call the method

xiaoxiao2021-03-06  17

Generally, we call a class of methods, which is called through this class itself (Static method) or one of its instances.

such as:

Interface iService

{

Void RunService (iconText Context);

}

Class Servicea: iService

{

Public override void runservice () // Inherited from the interface

{

//achieve

}

Public ArrayList GetServiceList (iconText ICXT)

{

//achieve....

}

}

When you can only use iService to receive Servicea instances, it is unable to call its GetServiceList () method.

IService Servicea ();

In this case, use another method to call:

// instance parameters

IContext Context = New Context ("UserName");

Object [] o = new object [1]; o [0] = context;

//

IService Service = GetServiceFromOrPlace ("Servicea");

// Call method getServiceList. Invoke () used to pass parameter service.gettype (). GetMethod ("getServiceList"). Invoke (Service, O);

ArrayList List = (arraylist) Context.Response.getValue ("ServiceList");

This can also achieve the purpose of calling the GetServiceList method.

转载请注明原文地址:https://www.9cbs.com/read-45188.html

New Post(0)