G
Guest
In C# 2, this works just fine:
public class foo : IEnumerable<string>
{
private string[] _list;
public IEnumerator<string> GetEnumerator()
{
foreach (string s in _list)
yield return s;
}
}
However Orcas complains that:
'myNS.foo' does not implement interface member
'System.Collections.IEnumerable.GetEnumerator()'. 'myNS.foo.GetEnumerator()'
cannot implement 'System.Collections.IEnumerable.GetEnumerator()' because it
does not have the matching return type of 'System.Collections.IEnumerator'.
It appears that I'll have to add an explicit non-generic interface
implementation to appease the compiler:
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
Just wondering whether this is a change in generics implementation or just a
bug in beta 1.
Cheers,
Don
public class foo : IEnumerable<string>
{
private string[] _list;
public IEnumerator<string> GetEnumerator()
{
foreach (string s in _list)
yield return s;
}
}
However Orcas complains that:
'myNS.foo' does not implement interface member
'System.Collections.IEnumerable.GetEnumerator()'. 'myNS.foo.GetEnumerator()'
cannot implement 'System.Collections.IEnumerable.GetEnumerator()' because it
does not have the matching return type of 'System.Collections.IEnumerator'.
It appears that I'll have to add an explicit non-generic interface
implementation to appease the compiler:
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
Just wondering whether this is a change in generics implementation or just a
bug in beta 1.
Cheers,
Don