C# 7 getter 및 setter 스타일 (또는 다른 새로운 언어 기능)을 자동으로 적용 할 수있는 방법이 있습니까?자동으로 C# 7 getter 및 setter 스타일 적용
자동으로 다음과 같은 속성을 변경할 수있는 방법이있을 것입니다 경우 그것은 좋은 것 : 이것에
public string MyProperty1
{
get
{
return this.myProperty1;
}
}
public string MyProperty2
{
get
{
return this.GetSomething();
}
set
{
this.SetSomething(value);
}
}
public string MyProperty3
{
get
{
return this.myProperty3;
}
set
{
this.myProperty3 = value;
this.RaisePropertyChange(nameof(MyProperty3));
}
}
을 :
public string MyProperty1 => this.myProperty1;
public string MyProperty2
{
get => this.GetSomething();
set => this.SetSomething(value);
}
public string MyProperty3
{
get => this.myProperty3;
set
{
this.myProperty3 = value;
this.RaisePropertyChange(nameof(MyProperty3));
}
}
어쩌면이이 작업을 처리 할 수있는 확장입니다 =)
미리 감사드립니다.
특별히 'MyProperty2'가 자동 속성이 아닌 배경 필드를 사용하게하려는 이유가 있습니까? – mjwills
@mjwills 내 질문을 편집했습니다. – WoIIe
누군가이 질문에 왜 많은 투표가 있었는지 나에게 설명해 줄 수 있습니까? 내 질문을 개선하고 싶다! =) – WoIIe