有一个Person类,代码如下:
public class Person
{ private string name;
private int age;
public string Name
{
get
{ return name; }
set
{ name = value; }
}
public int Age
{
get
{return age; }
set
{age=value;}
}
编写程序完成以下功能:
1)创建Person类的集合类people,该集合可以通过int型的索引符来访问.
2)在Person中重载>,<,比较Person实例的Age属性
3)给people添加GetOldest()方法,使用上面定义的重载运算符,返回一个Age最大的对象数组
4)在people类上执行ICloneable接口,提供深度复制功能
using
System;
using System.Collections; // Collections类用于使用对象数组
using System.Collections.Generic;
using System.Text;
namespace pro11
... {
public class Person:ICloneable //使用ICloneable接口
...{ private string name;
private int age;
public string Name
...{
get
...{ return name; }
set
...{ name = value; }
}
public int Age
using System.Collections; // Collections类用于使用对象数组
using System.Collections.Generic;
using System.Text;
namespace pro11
... {
public class Person:ICloneable //使用ICloneable接口
...{ private string name;
private int age;
public string Name
...{
get
...{ return name; }
set
...{ name = value; }
}
public int Age