-
[C#] Property, Get, SetC#/기초 2023. 3. 14. 14:07
public string Name=>"test";
같은 표현
class Employee { private string _name; // the name field public string Name => _name; // the Name property }
class Employee { private string _name; // the name field public string Name // the Name property { get => _name; } }
public static string => "some string value";
public static string Name { get { return "some string value"; } }
속성 사용 - C# 프로그래밍 가이드
다음 예제에서는 C#의 속성을 사용하는 방법을 보여줍니다. get 및 set 접근자가 읽기 및 쓰기 액세스를 구현하고 속성 사용법을 알아보는 방법을 확인합니다.
learn.microsoft.com
728x90'C# > 기초' 카테고리의 다른 글
[C#] sealed (0) 2023.05.28 [기초] String Format, 문자열 보간 $, @ (0) 2023.05.19 [C#] static, const, readonly (1) 2023.03.14 [C#] ! Null Forgiving Operator (0) 2023.03.06 [C#]형식 매개변수 제약 (0) 2023.01.17 댓글