namespace ConsoleApp1 { class Program { static void Main(string[] args) { People tom = new People() ; tom.Name =" Tom"; tom.Age = 18; tom.MyPlace = Co ...
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
People tom = new People() ;
tom.Name =" Tom";
tom.Age = 18;
tom.MyPlace = Console.ReadLine();
Console.WriteLine(tom.MyPlace);
Console.ReadKey();
}
}
public class People
{
public string Name;
public int Age;
public string MyPlace
{
get
{
return MyPlace;
}
set
{
if (value == "北京")
{
MyPlace = value;
}
else
{
MyPlace = "不符合要求";
}
}
}
}
}