using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AttributeTest
{
class Program
{
static void Main(string[] args)
{
Human.Age = 30;//通过属性给字段赋值
Console.WriteLine(Human.printInfo().ToString());
Console.ReadKey();
}
class Human
{
private static int age;
public static int Age //类的属性
{
get { return age; }
set
{
if(value>0)
{
age = value;
}
else
{
age = 0;
}
}
}
public static int printInfo()
{
return age;
}
}
}
}