的一些基本练习好的,这是练习: 设置一个名为“Date”的结构,其中包含date,包括年,月和日。另外,定义一个名为“电话”的类,其中包含姓名,号码,出生日期和地址。需要创建一个包含Phone类型对象的数组,并按名称,数字和日期对它们进行排序。 这是我的代码:struct
struct Date
{
int year, month, day;
public Date(int year, int month, int day)
{
this.year = year;
this.month = month;
this.day = day;
}
}
class Phone
{
int number;
string birthday, adress, name;
public Phone(int number, string birthday, string adress, string name)
{
this.number = number;
this.birthday = birthday;
this.adress = adress;
this.name = name;
}
}
class Program
{
static void Main(string[] args)
{
Phone[] p = new Phone[3];
for (int i = 0; i < p.Length; i++)
{
}
}
}
那么,事情是,我不知道如何从“手机”类获得结构的日期。 它假设是这样的权利?生日,年,等等。 谢谢。
您应该从生日被称为“出生日期”这一事实中得到提示。你创建了一个Date结构体......现在使用它。 –