Files
Ojt.Lectures/ExF.Class/MyCustomer.cs
T
2025-03-05 10:21:10 +09:00

57 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExF.Class
{
public class MyCustomer
{
// 필드
private string name;
private int age;
// 이벤트
public event EventHandler NameChanged;
// 생성자 (Constructor)
public MyCustomer()
{
name = string.Empty;
age = -1;
}
// 속성
public string Name
{
get { return this.name; }
set
{
if (this.name != value)
{
this.name = value;
if (NameChanged != null)
{
NameChanged(this, EventArgs.Empty);
}
}
}
}
public int Age
{
get { return this.age; }
set { this.age = value; }
}
// 메서드
public string GetCustomerData()
{
string data = string.Format("Name: {0} (Age: {1})",
this.Name, this.Age);
return data;
}
}
}