J
jcc
Hi guys,
I'm a newbie to C#. My Visual Studio 2005 failed to compile the
following code with error as
'HelloWorld.A' does not implement interface member
'System.Collections.IEnumerable.GetEnumerator()'.
'HelloWorld.A.GetEnumerator()' is either static, not public, or has the
wrong return type.
class A : IEnumerable<string>
{
string[] items = new string[100];
public IEnumerator<string> GetEnumerator()
{
foreach (string s in items)
yield return s;
}
}
Could you tell me what's wrong? It does not compile even if I copy the
example code from Programming C#, 4th Edition, although PC#'s example
is different with mine.
Thanks!
I'm a newbie to C#. My Visual Studio 2005 failed to compile the
following code with error as
'HelloWorld.A' does not implement interface member
'System.Collections.IEnumerable.GetEnumerator()'.
'HelloWorld.A.GetEnumerator()' is either static, not public, or has the
wrong return type.
class A : IEnumerable<string>
{
string[] items = new string[100];
public IEnumerator<string> GetEnumerator()
{
foreach (string s in items)
yield return s;
}
}
Could you tell me what's wrong? It does not compile even if I copy the
example code from Programming C#, 4th Edition, although PC#'s example
is different with mine.
Thanks!