我知道结构是值类型,但后来我不明白为什么这样有效:
编辑:我的意思是,为什么this.Size.Height不起作用呢?
struct A
{
int height;
public int Height
{
get
{
return height;
}
set
{
height = value;
}
}
}
//... class Main
{
A a = A();
a.Height = 5; //works. Why? I thought it should say "cannot modify as it is not variable". I think the properties should return copy of this struct...?
}
Run Code Online (Sandbox Code Playgroud)
第二个问题 - 我已经阅读过我不需要使用带有结构的"新"但如果没有它我就无法使用它.