We've expanded our news coverage and improved our search! Visit
oreilly.com for the latest or search for all things across O'Reilly!
Article:
 |
|
New Language Features in C# 2.0, Part 2
|
| Subject: |
|
Great intro, but bugifx |
| Date: |
|
2006-09-19 13:42:28 |
| From: |
|
ddelator
|
|
|
|
In your example you use a local variable to hold the arraylist. This will fail to provide enumeration or other base class operations, since you are not using the underlying container.
Here's an example that I've tried that works as expected.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace SignaturePrototype
{
public class ObjectList<ItemType> : CollectionBase
{
public int Add(ItemType value)
{
return InnerList.Add(value);
}
public void Remove(ItemType value)
{
InnerList.Remove(value);
}
public ItemType this[int index]
{
get
{
return (ItemType)InnerList[index];
}
set
{
InnerList[index] = value;
}
}
}
}
|