-
April 11th, 2010, 10:45 AM
#1
MSDN Graphs is wrong
Im using VS 2005. Im trying to make a graph work for a assignment. ive been using http://msdn.microsoft.com/en-US/libr...=VS.80%29.aspx to teach myself an use the code given, i downloaded the package at the start to extract the right code but it doesnt work i read somewhere that msdn code is wrong on this subject, if so does anyone know the solution ?
The problem is that in the Nodelist class- public class NodeList<T> : Collection<Node<T>>. The underline an in bold is the problem the error is "Collection cannot be found are you missing a directive or a assembly reference, i read that putting this in would help "using System.Collections.ObjectModel;"
This then causes another problem within the Graph class Error 'ClassLibary1.Graph<T>' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. does anyone know how to fix this problem any help if greatly appreciated.
Thanks Damien
-
April 12th, 2010, 12:00 PM
#2
Re: MSDN Graphs is wrong
So add the namesapace reference as you have already done and then implement the interface, i.e., write a method named "GetEnumerator" which returns an enumeration object. Your class likely maintains a member variable of the type Collection<Node<T>>, so just return the result of its GetEnumerator method.
-
April 13th, 2010, 05:43 AM
#3
Re: MSDN Graphs is wrong
isnt that this part of code?
public IEnumerator<T> GetEnumerator()
{
foreach (GraphNode<T> gnode in nodeSet)
yield return gnode.Value;
}
-
April 13th, 2010, 11:54 AM
#4
Re: MSDN Graphs is wrong
How about..
Code:
public IEnumerator<T> GetEnumerator( )
{
return nodeSet.GetEnumerator( );
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|