情景:
文件夹:连接
public class Connection
{
public void ServerConnect ()
{
. . . .
}
}
文件夹:客户
public void Connect
{
//In here, I want to implement the method from ServerConnect
}
如何调用ServerConnect?
答案 0 :(得分:1)
创建Connection
的对象,然后在其上调用ServerConnect()
:
public void Connect{
public void Foo(){
Connection con = new Connection();
con.ServerConnect();
}
}
答案 1 :(得分:0)
这就是你打电话给班级的方式。
public void Connect
{
//In here, I want to implement the method from ServerConnect
Connection c = new Connection();
c.ServerConnect();
}
答案 2 :(得分:0)
只需为Connection类创建对象并调用类似
的方法Connection obj=new Connection();
obj.ServerConnect();