G
Gawel
Hajo,
compiling below code I get following error:
Error 1 'ServerTreeConsoleApplication.ServerControlsTree' does not
implement interface member
'System.Collections.IEnumerable.GetEnumerator()'.
'ServerTreeConsoleApplication.ServerControlsTree.GetEnumerator()' is
either static, not public, or has the wrong return
type. E:\Work\Trials\ServerTreeConsoleApplication\ServerTreeConsoleApplication\ServerControlsTree.cs 7 18 ServerTreeConsoleApplication
Can someone explain me why?
thanks in advance for info
Gawel
public class ServerControlsTree : IEnumerable<ServerControl>
{
private ServerControl _root;
public ServerControl Root
{
get { return _root; }
set { _root = value; }
}
private ServerControl _enumerationRoot;
public ServerControl EnumerationRoot
{
get { return _enumerationRoot; }
set { _enumerationRoot = value; }
}
public IEnumerator<ServerControl> GetEnumerator()
{
List<ServerControl> controls = new List<ServerControl>();
controls.Add(_root);
for (int i = 0; i < controls.Count; i++)
{
yield return controls;
foreach (ServerControl childControl in
controls.Children)
{
controls.Add(childControl);
}
}
}
}
compiling below code I get following error:
Error 1 'ServerTreeConsoleApplication.ServerControlsTree' does not
implement interface member
'System.Collections.IEnumerable.GetEnumerator()'.
'ServerTreeConsoleApplication.ServerControlsTree.GetEnumerator()' is
either static, not public, or has the wrong return
type. E:\Work\Trials\ServerTreeConsoleApplication\ServerTreeConsoleApplication\ServerControlsTree.cs 7 18 ServerTreeConsoleApplication
Can someone explain me why?
thanks in advance for info
Gawel
public class ServerControlsTree : IEnumerable<ServerControl>
{
private ServerControl _root;
public ServerControl Root
{
get { return _root; }
set { _root = value; }
}
private ServerControl _enumerationRoot;
public ServerControl EnumerationRoot
{
get { return _enumerationRoot; }
set { _enumerationRoot = value; }
}
public IEnumerator<ServerControl> GetEnumerator()
{
List<ServerControl> controls = new List<ServerControl>();
controls.Add(_root);
for (int i = 0; i < controls.Count; i++)
{
yield return controls;
foreach (ServerControl childControl in
controls.Children)
{
controls.Add(childControl);
}
}
}
}