将一个类中的变量设置为等于来自另一个类的变量

时间:2017-11-18 03:42:09

标签: c#

我想从另一个类(Class2)获取变量xx,并将其设置为等于form1.cs中的变量mouseX。

form1.cs的示例代码:

private void canvas_MouseClick(object sender, MouseEventArgs e)
    {
        mouseX = Cursor.Position.X;
        mouseY = Cursor.Position.Y;
        //I am thinking here I could do Class2.xx = mouseX in order to set the variable xx 
        // equal to the newly acquired mouseX value, but this is not the case
    }

0 个答案:

没有答案