使用spel将对象(从dll创建)传递到C#上的其他类文件

使用spel将对象(从dll创建)传递到C#上的其他类文件,c#,class,object,robot,C#,Class,Object,Robot,有人能建议我如何将类程序传递到另一个类文件吗? 我的代码: (主表格) 机器人类 class Robot public void goToPt(SpelPoint point,int x,int y,int z) { point.X=point.X+x; m_spel.Go(point); // Want to use this function direct from class } } class Robot { public void goToPt(SpelNetLib.Sp

有人能建议我如何将类程序传递到另一个类文件吗? 我的代码: (主表格)

机器人类

class Robot
public void goToPt(SpelPoint point,int x,int y,int z)
{
 point.X=point.X+x;
 m_spel.Go(point); // Want to use this function direct from class
}
}
class Robot
{
    public void goToPt(SpelNetLib.Spel m_spel, SpelPoint point,int x,int y,int z)
    {
        point.X=point.X+x;
        m_spel.Go(point); 
    }
}

希望有人能帮忙?谢谢。

您可以将其作为参数传入:

private SpelNetLib.Spel m_spel;
Robot robot = new Robot();

private void startBt_ButtonClick(object sender, EventArgs e)
{
    SpelPoint pt = new SpelPoint();
    pt = m_spel.GetPoint("P*");
    pt.X = (float)125.5;   
    robot.goTOPT(m_spel, pos,10,5,5);
}
机器人类

class Robot
public void goToPt(SpelPoint point,int x,int y,int z)
{
 point.X=point.X+x;
 m_spel.Go(point); // Want to use this function direct from class
}
}
class Robot
{
    public void goToPt(SpelNetLib.Spel m_spel, SpelPoint point,int x,int y,int z)
    {
        point.X=point.X+x;
        m_spel.Go(point); 
    }
}

您需要添加对主项目中其他项目的引用。之后,您将能够使用ROBOT classAdd
m_spel
作为
goToPt
的参数。