C#7のゲッターとセッターのスタイル(または他の新しい言語の機能)を自動的に適用する方法はありますか?C#7のゲッターとセッターのスタイルを自動的に適用する
自動的にこれらのようなプロパティを変更するにはどのような方法が存在することになる場合、それはいいだろう。これまで
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