struct node
{
    string data;
    node[] next;
}node top;top.next = new node();    //这里有错误,不能这样做,怎么办?

解决方案 »

  1.   

    链表不要用stuct
    会造成循环引用,编译通不过的
    用Class
      

  2.   

    ArrayList在大多数时候都够用了,只不过要是你需要特别处理的话...可以自己写类
    class node {
      object value;
      node prev;
      node next; //..要是要双向链表的话...
      
      public node(object value,node prev,node next){
          this.prev = prev;
          this.next = next;
          this.value = value;
      }
      
    //递归的遍历,当然也可以写不递归的 
      public static travel(node current){
          Console.WriteLine(current.value.toString());
          if(current.Next!= null){
            travel(current.Next);
          }
      }
    }
      

  3.   

    使用List<T> list=new List<T>()实例化一个泛型链表,不过是单链表。