我的结构有问题 :),编译器给我错误
"An object reference is required for the non-static field, method, or property 'SonyasProgram.Form1.frameLimits.Max.Y.get'"
我曾尝试寻找解决方案,但没有一个特别清楚。这是我的代码:
public partial class Form1 : Form
{
public struct frameLimits
{
public struct Max
{
private int yval = 220;
public int Y
{
get
{
return yval;
}
set
{
yval = value;
}
}
}
}
public Form1()
{
frameLimits.Max.Y = 1;
最后一行是识别错误的地方。任何帮助都会很棒,谢谢!
请您参考如下方法:
正如编译器告诉您的那样,您正在尝试执行需要静态变量的操作。您要么想要创建 frameLimits 的实例,要么更有可能将 yval 声明为 static。
