我有这堂课:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerGraphicsExercises
{
class Adamak
{
public int BodyX1;
public int BodyX2;
public int HeadX;
public int LeftArmX1;
public int LeftArmX2;
public int RightArmX1;
public int RightArmX2;
public int LeftLegX1;
public int LeftLegX2;
public int RightLegX1;
public int RightLegX2;
public int LeftEyeX;
public int RightEyeX;
public int PupilOfLeftEyeX;
public int PupilOfRightEyeX;
public int NoseX;
public int LipsX;
public int HairX;
public int LeftEarX;
public int RightEarX;
public int BodyY1;
public int BodyY2;
public int HeadY;
public int LeftArmY1;
public int LeftArmY2;
public int RightArmY1;
public int RightArmY2;
public int LeftLegY1;
public int LeftLegY2;
public int RightLegY1;
public int RightLegY2;
public int LeftEyeY;
public int RightEyeY;
public int PupilOfLeftEyeY;
public int PupilOfRightEyeY;
public int NoseY;
public int LipsY;
public int HairY;
public int LeftEarY;
public int RightEarY;
}
}
我宣布了一个这样的变量:
namespace ComputerGraphicsExercises
{
public partial class Main : Form
{
Adamak iMan2 = new Adamak();
}
}
现在我要更改:
的值iMan2.BodyX1 = 50;
但是我收到了这个错误:
错误1类,结构或接口成员中的标记'='无效 声明C:\ vc \ ComputerGraphicsExercises \ ComputerGraphicsExercises \ Main.cs 17 22 ComputerGraphicsExercises
我的错误是什么?
答案 0 :(得分:1)
您可以在任何构造函数或方法之外为类的实例的字段赋值。这就是为什么