これは練習です: 年、月、日を含む日付を含む "Date"という構造体を設定します。また、名前、番号、生年月日、住所を含む "Phone"というクラスを定義します。 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構造体を作成しました...今、それを使用します。 –