프로퍼티
public class Person
{
private string name; // 백킹 필드
public string Name
{
get { return name; }
set { name = value; }
}
}
public class Person
{
public string Name { get; set; }
}
public class Person
{
private int age;
public int Age
{
get { return age; }
set
{
if (value < 0)
throw new ArgumentException("Age cannot be negative");
age = value;
}
}
}
Action Func (0) | 2024.06.21 |
---|---|
인터페이스(interface) (0) | 2024.06.21 |
델리게이트, 이벤트 (0) | 2024.06.20 |
구조체(Struct), 열거형(enum) (0) | 2024.06.19 |
arrayList, List, Hashtable, Dictionary, Queue, Stack (0) | 2024.06.19 |