关于继承虚拟类的问题
taia 2005-04-27 10:56:32 //以下是完整的代码
using System;
using System.Collections;
class Test
{
public static void Main(){
DateCollection s=new DateCollection();
s.Add(DateTime.Now);
}
}
public class DateCollection : CollectionBase
{
public int Add(DateTime value)
{
return (List.Add(value));
}
public void Remove( DateTime value )
{
List.Remove( value );
}
public bool Contains(DateTime value)
{
return (List.Contains(value));
}
//问题出在下面这个方法中
public override void RemoveAt(int index)
{
base.RemoveAt(index);
}
public void Insert (int index,DateTime value)
{
List.Insert(index,value);
}
public DateTime this[int index]
{
get
{
return ((DateTime)List[index]);
}
set
{
List[index]=value;
}
}
}
//======================================
编译提示出错
"jc.cs(43,25): error CS0506: “DateCollection.RemoveAt(int)” : 无法重写继承成员“System.Collections.CollectionBase.RemoveAt(int)”,因为它未标记为 virtual、abstract 或 override"
大家可以翻一下SDK文档,System.Collections.CollectionBase.RemoveAt(int)这个方法的签名是
[C#]
public virtual void RemoveAt(
int index
);
明白着是虚方法啊,并且还是PUBLIC类型的
我的程序为什么会这样呢