Is it possible to execute some code specific to my list instance when an item is removed from it? I want to re-number ID #s (a field in my list) every time an item is removed.
EDIT:
I think I've found what I am looking for. In my own words... I am now deriving a class from a Generic List. This seems to let me extend the add and remove methods to perform the specific house keeping to the data that I require.
class DeviceDataTable<T> : IEnumerable<T>
{
private List<T> table = new List<T>();
public void AddRow(T r)
{
table.Add(r);
//Add ID management
}
public void RemoveRow(Int32 i)
{
table.RemoveAt(i);
//Add ID management
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return table.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return table.GetEnumerator();
}
}
I am getting errors on the implementation of the second interface (IEnumerator IEnumerable.GetEnumerator();). It states "Using the generic type 'Systems.Collections.Generic.IEnumerator<T>' requires '1' type arguments. Any thoughts on why?

0 answers