728x90
반응형
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Property
{
internal class Program
{
/*
class BirthdayInfo
{
private string name;
private DateTime birthday;
public string Name
{
get { return name; }
set { name = value; }
}
public DateTime Birthday
{
get { return birthday; }
set { birthday = value; }
}
public int Age
{
get
{
return new DateTime(DateTime.Now.Subtract(birthday).Ticks).Year;
}
}
}
*/
/*
class BirthdayInfo
{
public string Name { get; set; } = "Unknown";
public DateTime Birthday { get; set; } = new DateTime(1, 1, 1);
public int Age
{
get
{
return new DateTime(DateTime.Now.Subtract(Birthday).Ticks).Year;
}
}
}
*/
/*
class BirthdayInfo
{
public string Name
{
get; set;
}
public DateTime Birthday
{
get; set;
}
public int Age
{
get
{
return new DateTime(DateTime.Now.Subtract(Birthday).Ticks).Year;
}
}
}
*/
static void Main(string[] args)
{
/*
BirthdayInfo birth = new BirthdayInfo
{
Name = "서현",
Birthday = new DateTime(1991, 6, 28)
};
Console.WriteLine($"Name : {birth.Name}");
Console.WriteLine($"Birthday : {birth.Birthday.ToShortDateString()}");
Console.WriteLine($"Age : {birth.Age}");
/*
/*
BirthdayInfo birth = new BirthdayInfo();
birth.Name = "홍길동";
birth.Birthday = new DateTime(1991, 6, 26);
Console.WriteLine($"Name : {birth.Name}");
Console.WriteLine($"Birthday : {birth.Birthday.ToShortDateString()}");
Console.WriteLine($"Age : {birth.Age}");
birth.Name = "서현";
birth.Birthday = new DateTime(1991, 6, 28);
Console.WriteLine($"Name : {birth.Name}");
Console.WriteLine($"Birthday : {birth.Birthday.ToShortDateString()}");
Console.WriteLine($"Age : {birth.Age}");
*/
}
}
}
728x90
반응형
댓글