class Test
{
private int _aa;
public int AA
{
set
{
if (value > 100 || value < 0) value = 0;
_aa = value;
}
get
{
return _aa;
}
}
}
class Program
{
static void Main(string[] args)
{
Test t = new Test();
t.AA = 101;
Console.WriteLine(t.AA); //输出0
Console.ReadKey();
}
}