即时尝试了解字段的获取和设置属性,并运行到这个问题,可以somone解释为什么我必须使int X字段静态,使其工作?静态字段问题
using System;
namespace ConsoleApplication1
{
class Program
{
public static int X = 30;
public static void Main()
{
var cX = new testme();
cX.intX = 12;
Console.WriteLine(cX.intX);
cX.intX = X;
Console.WriteLine(cX.intX);
Console.ReadKey();
}
}
class testme
{
public int intX
{
get;
set;
}
}
}
啊oki我明白了,thx的解释 – Darkmage 2009-11-29 14:19:57