コンストラクターについていくつかアドバイスをもらいましたが、今ではたくさんあります。これらを関数または他の方法で単純化できますか? これが私のクラスですか?
public class ContentViewModel
{
public ContentViewModel() { }
public ContentViewModel(Content content)
{
this.Content = content;
}
public ContentViewModel(string pk)
{
this.Content = new Content();
this.Content.PartitionKey = pk;
this.Content.Created = DateTime.Now;
}
public ContentViewModel(string pk, string rk)
{
this.Content = new Content();
this.Content.PartitionKey = pk;
this.Content.RowKey = rk;
this.Content.Created = DateTime.Now;
}
public ContentViewModel(string pk, string rk, string user)
{
this.Content = new Content();
this.Content.PartitionKey = pk;
this.Content.RowKey = rk;
this.Content.Created = DateTime.Now;
this.Content.CreatedBy = user;
}
public Content Content { get; set; }
public bool UseRowKey {
get {
return this.Content.PartitionKey.Substring(2, 2) == "05" ||
this.Content.PartitionKey.Substring(2, 2) == "06";
}
}
public string TempRowKey { get; set; }
}
私はc#4を使用しています。名前付き引数とオプション引数について誰かが言いました。それは私を助けますか?