public class YourClassCollection : CollectionBase
{
public YourClassCollection()
{
}
public void Add(YourClass item)
{
List.Add(item);
} public void Remove(int index)
{
if (index > Count - 1 || index < 0)
{
throw( new Exception(String.Format("ͼɾڵԪλ:{0}", index)));
}
else
{
List.RemoveAt(index);
}
} public YourClass this[int index]
{
get
{
return (YourClass)List[index];
}
set
{
List[index] = value;
}
}
}
{
public YourClassCollection()
{
}
public void Add(YourClass item)
{
List.Add(item);
} public void Remove(int index)
{
if (index > Count - 1 || index < 0)
{
throw( new Exception(String.Format("ͼɾڵԪλ:{0}", index)));
}
else
{
List.RemoveAt(index);
}
} public YourClass this[int index]
{
get
{
return (YourClass)List[index];
}
set
{
List[index] = value;
}
}
}
解决方案 »
- 无法关闭 PowerPoint 进程
- 关于datagridview两个combox列数据显示问题
- 类实现一个接口,可以用接口声明这个类吗?
- windows服务程序不行啊
- 调用COM组件的问题
- C#如何读取一个程序集(*.exe,*.dll)里的数据
- DataGridColumnStyle.ReadOnly问题
- 我想把tdes.Key(byte[])写入文件d:\\testfile.bin,然后再读出来赋值给byte[] t。怎么写呢?用c#
- 串口通讯的问题。请高手进来
- 当我使用[assambly: AssamblyKeyFile("test.snk")] 时编译器说使用重复属性,这是什么原因
- 把主从的主表放到一DataGrid中,如何判断当前点击的是主表还是从表?
- 关于DBNull
class MyItem
{
private SomeCollection values; //SomeCollection含有索引器属性
public object Values[int indexer]
{
get {
return values[indexer];
}
set {
values[indexer]=(SomeCollection)value;
}
}
}
sc[0] = "1";MyItem item = new MyItem();
item.Values = sc;