S
Siegfried Heintze
Can someone help me implement a singly linked list class as a exercise? I'm
getting the following syntax error:
Error 1 'SinglyLinkedListNode<T>.IEnumerable<...>.GetEnumerator()':
containing type does not implement interface
'System.Collections.Generic.IEnumerable<T>' F:\SinglyLinkedList.cs 17 24
InQLinkedList
I've been google searching and I have found others with this same error. In
fact, that is where I got these troublesome lines of code. But the solution
that works for them does not work for me!
What am I doing wrong?
Thanks,
Siegfried
P.S. Scrolll way down to find my version information.
Here is my attempt:
class SinglyLinkedListNode<T> //:IEnumerable<T>
{
public IEnumerator<T> GetEnumerator() { SinglyLinkedListNode<T> list = this;
while (list != null) { yield return list.data; list = list.next; } }
IEnumerator<T> IEnumerable<T>.GetEnumerator() { return GetEnumerator(); }
//IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
private T data;
private SinglyLinkedListNode<T> next;
public SinglyLinkedListNode(T data) { this.data = data; next = null; }
public SinglyLinkedListNode(T data, SinglyLinkedListNode<T> tail) {
this.data = data; next = tail; }
}
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
Installed Edition: Standard
Microsoft Silverlight Projects 2008 91851-136-3759112-60601
Microsoft Silverlight Projects 2008
Version 9.0.30730.126
Microsoft Visual Basic 2008 91851-136-3759112-60601
Microsoft Visual Basic 2008
Microsoft Visual C# 2008 91851-136-3759112-60601
Microsoft Visual C# 2008
Microsoft Visual C++ 2008 91851-136-3759112-60601
Microsoft Visual C++ 2008
Microsoft Visual Web Developer 2008 91851-136-3759112-60601
Microsoft Visual Web Developer 2008
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB944899)
KB944899
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/944899.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB945282)
KB945282
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/945282.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946040)
KB946040
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946040.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946308)
KB946308
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946308.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946344)
KB946344
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946344.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946581)
KB946581
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946581.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB947173)
KB947173
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947173.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB947540)
KB947540
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947540.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB947789)
KB947789
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947789.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB948127)
KB948127
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/948127.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB953256)
KB953256
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/953256.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB971092)
KB971092
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/971092.
Microsoft Visual Studio 2008 Standard Edition - ENU Service Pack 1
(KB945140) KB945140
This service pack is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/945140.
Microsoft Visual Studio 2008 Standard Edition - ENU Service Pack 1
(KB947888) KB947888
This service pack is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947888.
Microsoft Visual Studio 2008 Standard Edition - ENU Service Pack 1
(KB948484) KB948484
This service pack is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/948484.
Security Update for Microsoft Visual Studio 2008 Standard Edition - ENU
(KB972222) KB972222
This security update is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this security update will
be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/972222.
Update for Microsoft Visual Studio 2008 Standard Edition - ENU (KB956453)
KB956453
This update is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this update will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/956453.
Update for Microsoft Visual Studio 2008 Standard Edition - ENU (KB967143)
KB967143
This update is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this update will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/967143.
getting the following syntax error:
Error 1 'SinglyLinkedListNode<T>.IEnumerable<...>.GetEnumerator()':
containing type does not implement interface
'System.Collections.Generic.IEnumerable<T>' F:\SinglyLinkedList.cs 17 24
InQLinkedList
I've been google searching and I have found others with this same error. In
fact, that is where I got these troublesome lines of code. But the solution
that works for them does not work for me!
What am I doing wrong?
Thanks,
Siegfried
P.S. Scrolll way down to find my version information.
Here is my attempt:
class SinglyLinkedListNode<T> //:IEnumerable<T>
{
public IEnumerator<T> GetEnumerator() { SinglyLinkedListNode<T> list = this;
while (list != null) { yield return list.data; list = list.next; } }
IEnumerator<T> IEnumerable<T>.GetEnumerator() { return GetEnumerator(); }
//IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
private T data;
private SinglyLinkedListNode<T> next;
public SinglyLinkedListNode(T data) { this.data = data; next = null; }
public SinglyLinkedListNode(T data, SinglyLinkedListNode<T> tail) {
this.data = data; next = tail; }
}
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
Installed Edition: Standard
Microsoft Silverlight Projects 2008 91851-136-3759112-60601
Microsoft Silverlight Projects 2008
Version 9.0.30730.126
Microsoft Visual Basic 2008 91851-136-3759112-60601
Microsoft Visual Basic 2008
Microsoft Visual C# 2008 91851-136-3759112-60601
Microsoft Visual C# 2008
Microsoft Visual C++ 2008 91851-136-3759112-60601
Microsoft Visual C++ 2008
Microsoft Visual Web Developer 2008 91851-136-3759112-60601
Microsoft Visual Web Developer 2008
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB944899)
KB944899
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/944899.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB945282)
KB945282
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/945282.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946040)
KB946040
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946040.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946308)
KB946308
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946308.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946344)
KB946344
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946344.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB946581)
KB946581
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/946581.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB947173)
KB947173
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947173.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB947540)
KB947540
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947540.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB947789)
KB947789
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947789.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB948127)
KB948127
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/948127.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB953256)
KB953256
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/953256.
Hotfix for Microsoft Visual Studio 2008 Standard Edition - ENU (KB971092)
KB971092
This hotfix is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this hotfix will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/971092.
Microsoft Visual Studio 2008 Standard Edition - ENU Service Pack 1
(KB945140) KB945140
This service pack is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/945140.
Microsoft Visual Studio 2008 Standard Edition - ENU Service Pack 1
(KB947888) KB947888
This service pack is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/947888.
Microsoft Visual Studio 2008 Standard Edition - ENU Service Pack 1
(KB948484) KB948484
This service pack is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/948484.
Security Update for Microsoft Visual Studio 2008 Standard Edition - ENU
(KB972222) KB972222
This security update is for Microsoft Visual Studio 2008 Standard Edition -
ENU.
If you later install a more recent service pack, this security update will
be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/972222.
Update for Microsoft Visual Studio 2008 Standard Edition - ENU (KB956453)
KB956453
This update is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this update will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/956453.
Update for Microsoft Visual Studio 2008 Standard Edition - ENU (KB967143)
KB967143
This update is for Microsoft Visual Studio 2008 Standard Edition - ENU.
If you later install a more recent service pack, this update will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/967143.