Hi,
You are missing the non-generic version. IEnumerable<Timplements
IEnumerable.
Both must be implemented, but commonly the non-generic version is
implemented explicitly and just calls the generic version:
class TestIEnum : IEnumerable<string>
{
public IEnumerator<stringGetEnumerator()
{
...
}
System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
--
Dave Sexton
"rossum" <rossum48@coldmail.comwrote in message
news:q8nhm29p7t025e5d7bl7dlgmfn4h33u4pn@4ax.com...
Quote:
>I have been trying to get the IEnumerable interface to compile, and am
having some difficulties.
>
When I try to compile:
>
class TestIEnum : IEnumerable<string{
>
string[] theStrings;
>
public IEnumerator<stringGetEnumerator() {
foreach (string s in theStrings) {
yield return s;
}
}
} // end class TestIEnum
>
I get the error message: "'TestIEnum' does not implement interface
member 'System.Collections.IEnumerable.GetEnumerator()'.
'TestIEnum.GetEnumerator()' is either static, not public, or has the
wrong return type."
>
I can see that GetEnumerator() is public and not static, so I assume
my error is in the return type. I have tried both string and the
non-generic IEnumerator as return types, neither works.
>
I noticed that the error message refers to
System.Collections.IEnumerable.GetEnumerator(), the non-generic
version. So I tried fully qualifying the name of GetEnumerator(),
again no joy.
>
What am I missing here?
>
Thanks in advance,
>
rossum
>
>