Removing Vertex

Jun 30, 2009 at 5:52 PM

Something this simple is giving me a lot of headache! Why do I get this error message?

private void removeTransitionButton_Click(object sender, EventArgs e)
        {
            if (this.transitionListBox.SelectedItem != null)
            {
                Diagram d = (Diagram)((DocumentChild)((DockPanel)this.ParentForm.Parent.Parent.Parent).ActiveDocument).ElementHost.Child;


                d.GraphToVisualize.RemoveEdge(
                    d.GraphToVisualize.Edges.First<Edge<object>>(
                        delegate(Edge<object> edge)
                        {
                            return true;
                        })
                    );
            }
        }

 

Error    1    'System.Collections.Generic.IEnumerable<QuickGraph.IEdge<object>>' does not contain a definition for 'First' and the best extension method overload 'System.Linq.Queryable.First<TSource>(System.Linq.IQueryable<TSource>, System.Linq.Expressions.Expression<System.Func<TSource,bool>>)' has some invalid arguments    F:\Documents and Settings\Enrique\My Documents\Visual Studio 2008\Projects\PFCEditor\PFCEditor\TransitionListPanel.cs    60    21    PFCEditor
Error    2    Instance argument: cannot convert from 'System.Collections.Generic.IEnumerable<QuickGraph.IEdge<object>>' to 'System.Linq.IQueryable<QuickGraph.Edge<object>>'    F:\Documents and Settings\Enrique\My Documents\Visual Studio 2008\Projects\PFCEditor\PFCEditor\TransitionListPanel.cs    60    21    PFCEditor
Error    3    Argument '2': cannot convert from 'anonymous method' to 'System.Linq.Expressions.Expression<System.Func<QuickGraph.Edge<object>,bool>>'    F:\Documents and Settings\Enrique\My Documents\Visual Studio 2008\Projects\PFCEditor\PFCEditor\TransitionListPanel.cs    61    25    PFCEditor
Error    4    Unknown build error, 'Could not load file or assembly 'file:///F:\Documents and Settings\Enrique\My Documents\Visual Studio 2008\Projects\PFCEditor\PFCEditor\obj\Debug\PFCEditor.exe' or one of its dependencies. The system cannot find the file specified. Line 8 Position 14.'     F:\Documents and Settings\Enrique\My Documents\Visual Studio 2008\Projects\PFCEditor\PFCEditor\Diagram.xaml    8    14    PFCEditor

 

I know the "return true" is kinda idiotic when I could use a simple "First();" but it's just to simplify :)

Coordinator
Jul 1, 2009 at 5:50 AM

Looks like you are missing a namespace. My advice: don't use extension methods. Write Enumerable.First(d.GraphToVisualize.Edges) and intellisense will tell you the rest. There might be helpers for that in GraphExtensions too.