Overloading Fail For Enumerator in C#
I want to implement a IEnumerator. But It causes a error
public class WachableDictionaryEnumerator : IEnumerator<TVal>
{
private TVal[] a;
private int len;
public bool MoveNext()
{
len = len + 1;
return len < a.Length;
}
public object Current
{
get
{
return a[len];
}
}
public TVal Current
{
get
{
return a[len];
}
}
public void Dispose()
{
a = null;
len = 0;
}
public void Reset()
{
len = 0;
}
}
The error is:
Error 5 The type
'CPS.Manipulation.WatchableDictionary.WachableDictionaryEnumerator'
already contains a definition for 'Current' D:\CE\Supins\Cyan Pembuat
Soal\Required Manipulation\Class1.cs 32 25 Required Manipulation
But if I delete one of Current object, then the error is
Error 21
'CPS.Manipulation.WatchableDictionary.WachableDictionaryEnumerator' does
not implement interface member
'System.Collections.Generic.IEnumerator.Current'.
'CPS.Manipulation.WatchableDictionary.WachableDictionaryEnumerator.Current'
cannot implement 'System.Collections.Generic.IEnumerator.Current' because
it does not have the matching return type of 'TVal'. D:\CE\Supins\Cyan
Pembuat Soal\Required Manipulation\Class1.cs 16 22 Required Manipulation
Help me to fix the code.
No comments:
Post a Comment