これは私を驚かせたものであり、これがまったく可能かどうか疑問に思っています。
簡単に言うと、コードは次のとおりです。
public class NotificationCollection : ObservableCollection<Notification>
{
public NotificationCollection() : base()
{
this.CollectionChanged += NotificationCollection_CollectionChanged;
this.PropertyChanged += NotificationCollection_PropertyChanged;
}
public NotificationCollection(IEnumerable<Notification> items)
: base(items)
{
this.CollectionChanged += NotificationCollection_CollectionChanged;
this.PropertyChanged += NotificationCollection_PropertyChanged;
}
(....)
}
ご覧のとおり、コードを複製しています。継承されたクラスを作成していなかったら、次のように書きます
public NotificationCollection(IEnumerable<Notification> items)
: this() //I can just call the empty constructor
{
//do stuff here...
//however, in case of inheritance this would be handled by base(items)
}
だから、私の質問は -base
クラスコンストラクターとコンストラクターの両方を呼び出すことができthis
ますか?