CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Posts
    2

    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

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    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.

  3. #3
    Join Date
    Apr 2010
    Posts
    2

    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;
    }

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    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
  •  





Click Here to Expand Forum to Full Width

Featured