读书人

请高手帮忙纠错吧.小弟我已经不行了

发布时间: 2011-12-21 23:56:01 作者: rapoo

请高手帮忙纠错吧.我已经不行了
public interface IEnumerator
{
bool MoveNext();
object Current { get; }
void Reset();
}
public interface IEnumerable
{
IEnumerator GetEnumerator();
}
public sealed class Evidence : ICollection, IEnumerable
{
// Fields
private IList m_assemblyList;
private IList m_hostList;
private bool m_locked;
public IEnumerator GetEnumerator()
{
return new EvidenceEnumerator(this);
}
public IEnumerator GetAssemblyEnumerator()
{
if (this.m_assemblyList == null)
{
this.m_assemblyList = ArrayList.Synchronized(new ArrayList());
}
return this.m_assemblyList.GetEnumerator();
}
public IEnumerator GetHostEnumerator()
{
if (this.m_hostList == null)
{


this.m_hostList = ArrayList.Synchronized(new ArrayList());
}
return this.m_hostList.GetEnumerator();
}
public void CopyTo(Array array, int index)
{
int num = index;
if (this.m_hostList != null)
{
this.m_hostList.CopyTo(array, num);
num += this.m_hostList.Count;
}
if (this.m_assemblyList != null)
{
this.m_assemblyList.CopyTo(array, num);
}
}
public int Count
{
get
{
return (((this.m_hostList != null) ? this.m_hostList.Count : 0) + ((this.m_assemblyList != null) ? this.m_assemblyList.Count : 0));
}
}
public object SyncRoot
{


get
{
return this;
}
}
public bool IsSynchronized
{
get
{
return false;
}
}
}
错误“mycontrol.Login.Evidence”不会实现接口成员“System.Collections.IEnumerable.GetEnumerator()”。“mycontrol.Login.Evidence.GetEnumerator()”或者是静态、非公共的,或者有错误的返回类型。请高手看看什么地方我弄错了.

[解决办法]
你定义了两个接口

public interface IEnumerator
{
bool MoveNext();
object Current { get; }
void Reset();
}
public interface IEnumerable
{
IEnumerator GetEnumerator();
}


然后再下面要实现
ICollection, IEnumerable这两个接口

你可知道
System.Collections下面已经有上面你定义的接口了
而编译器的就近原则,他找到的是你上面的两个接口,但你又没有实现以下几个方法

bool MoveNext();
object Current { get; }
void Reset();


看看是不是这样
我已经帮你检查调试过了

读书人网 >.NET

热点推荐