想想还是写一个给你:
public class StringList: ICollection
{
private ArrayList list;
private void EnsureList()
{
if (list == null)
{
list = new ArrayList();
}
}
public string this[int index]
{
get
{
if (list != null &&
index >= 0 &&
index < list.Count)
{
return (string) list[index];
}
return null;
}
set
{
while (Count <= index)
{
Add(string.Empty);
}
list[index] = value;
}
}
public void RemoveAt(int index)
{
if (list != null)
{
list.RemoveAt(index);
}
}
public void Insert(int index, string value)
{
EnsureList();
list.Insert(index, value);
}
public void Remove(string value)
{
if (list != null)
{
list.Remove(value);
}
}
public bool Contains(string value)
{
if (list != null)
{
return list.Contains(value);
}
return false;
}
public void Clear()
{
if (list != null)
{
list.Clear();
}
}
public int IndexOf(string value)
{
if (list != null)
{
return list.IndexOf(value);
}
return - 1;
}
public int Add(string value)
{
EnsureList();
return list.Add(value);
}
public override string ToString()
{
if (Count > 0)
{
string s = string.Empty;
for (int i = 0;
i < Count;
i++)
{
s += this + "/n";
}
return s;
}
return string.Empty;
}
#region ICollection 成员
public bool IsSynchronized
{
get
{
if (list != null)
{
return list.IsSynchronized;
}
return false;
}
}
public int Count
{
get
{
if (list != null)
{
return list.Count;
}
return 0;
}
}
public void CopyTo(Array array, int index)
{
if (list != null)
{
list.CopyTo(array, index);
}
}
public object SyncRoot
{
get
{
EnsureList();
return list;
}
}
#endregion
#region IEnumerable 成员
public IEnumerator GetEnumerator()
{
EnsureList();
return list.GetEnumerator(0, Count);
}
#endregion
}