Wednesday

Derive Collection class:Override Add,Insert,Remove methods

These methods are not overridable,
will be more correctly to override InsertItem,RemoveItem methods, they will be called from other methods Add,Insert,Remove , etc

using System.Collections.ObjectModel;
using System.Diagnostics;
using System;
namespace CollectionTest
{
class Program
{
static void Main(string[] args)
{
Debug.Write("MAIN");
LimitedCollection<String> col = new LimitedCollection<String>();
col.Add("hello");
col.Insert(0,"hello");

}
}
public class LimitedCollection<T> : Collection<T>
{
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
Debug.Write("InsertItem called");
}
}
}

more...

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...