我最近决定恢复我对C#基本原理的记忆,这样可能是三边的,但我会 following入以下问题:
StringCollection
was used in .NET v1.0 in order to create a strongly typed collection for strings as opposed to an object
based ArrayList
(this was later enhanced by including Generic collections):
快速浏览Stlection
下的定义,请参看:
// Summary:
// Represents a collection of strings.
[Serializable]
public class StringCollection : IList, ICollection, IEnumerable
{
...
public int Add(string value);
...
}
您可看到其执行<代码>IList,其中载有以下声明(其他几项声明):
int Add(object value);
但不是:
int Add(string value);
我的第一个假设是,这是有可能的。 NET框架一致规则。
因此,我只是为了保证,试图撰写我自己的班子,实施<代码>IList,并修改。
int Add(object value);
在试图汇编项目时,我发现一个编辑错误:
does not implement interface member System.Collections.IList.Add(object)
Any ideas what causes this?
感谢!