小编use*_*660的帖子

错误:无法将类型'System.Collections.Generic.LinkedListNode <Edge <T >>'隐式转换为'Edge <T>'

我使用以下代码获取链表工作清单的第一个元素,但我在第2行收到错误

Cannot implicitly convert type System.Collections.Generic.LinkedListNode<Edge<T>>' to 'Edge<T>'

  1. LinkedList<Edge<T>> worklist = new LinkedList<Edge<T>>();
  2. Edge<T> curr = worklist.First;

根据定义.首先上面的代码应该工作.请帮我解决这个问题.

类Edge的定义如下

private sealed class Edge<T>
{

            public  T start;
            public  T end;

    /// <summary>
    /// Constructs a new edge between the two indicated endpoints.
    /// </summary>
    /// <param name="start"> The edge's starting point. </param>
    /// <param name="end"> The edge's endpoint. </param>
    public Edge(T start, T end)
    {
        this.start = start;
        this.end = end;
    }
}
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
1
解决办法
1067
查看次数

标签 统计

c# ×1