由于“a”是键入的值,我有以下代码不起作用。但我认为即使没有访问器它也不会工作,但它确实:
class Program
{
a _a //with accessors it WONT compile
{
get;
set;
}
static void Main(string[] args)
{
Program p = new Program();
p._a.X = 5; //when both accessors are deleted, compiler does not
//complain about _a.X not being as variable
}
}
struct a
{
public int X;
}
它不起作用,因为“a”是结构。但是当我从“_a”实例中删除访问器时,它可以工作。我不懂为什么。谢谢