using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Class1
{
private string _name="haha";
private int _age;
public string _cardID;
public int Age
{
get
{
return _age;
}
set
{
if(value<0||value>100)
{
_age=19;
}
else{
_age=value;
}
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Class1 student = new Class1();
student.Age=-20;
Console.WriteLine("年龄:{0}", student.Age);
student.Age=40;
Console.WriteLine("年龄是:{0}", student.Age);
Console.ReadLine();
}
}
}
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication1{ class Class1 { private st