▲ 0 r/csharp
It feels like the language would be so much more flexible if they were, wouldn’t it? I started thinking about this while looking for a list implementation that automatically reacts to collection changes (by the way, do you know one?). If C# worked that way, I could simply write something like:
public class ModAlertList<T> : List<T>
{
public event EventHandler CollectionChanged;
public override void Add(T item)
{
base.Add(item);
CollectionChanged?.Invoke(this, EventArgs.Empty);
}
// ... same for Remove()
}
And there are tons of other examples like this.
So what’s the reason?
u/Alert-Neck7679 — 7 days ago