111,120
社区成员
发帖
与我相关
我的任务
分享
class Student
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
}
class Program
{
static void Main(string[] args)
{
Student stu = new Student();
stu.Name = "Chengtao";
stu.Age = 25;
AddAge(stu);
Student stu1 = new Student();
stu1.Name = "Hongwei";
stu1.Age = 26;
SubAge(ref stu1);
Console.WriteLine(stu.Age);
Console.WriteLine(stu1.Age);
Console.Read();
}
private static void AddAge(Student stu)
{
stu = new Student();
stu.Age = 20;
}
private static void SubAge(ref Student stu)
{
stu = new Student();
stu.Age = 30;
}
}