C#泛型继承代码出错
【求助】C#泛型继承代码出错
using System;
using P11_2;
namespace P11_5
{
public class BiLinkNode<T> : LinkNode<T>
{
protected BiLinkNode<T> previous;
protected new BiLinkNode<T> next;
public BiLinkNode<T> Previous // 获取或设置节点的前一个节点
{
get { return previous; }
set
{
previous = value;
if (previous != null && previous.Next != this)
previous.Next = this;
}
}
public new BiLinkNode<T> Next // 获取或设置节点的下一个节点
{
get { return next; }
set
{
next = value;
if (next != null && next.Next != this)
next.previous = this;
}
}
public BiLinkNode(T t) : base(t) { }
public static BiLinkNode<T> operator <<(BiLinkNode<T> node, int n) //移至node的第n个前驱节点
{
BiLinkNode<T> node1 = node;
for (int i = 0; i < n && node1 != null; i++)
node1 = node1.previous;
return node1;
}
}
}

下面上引用的P11_2的源代码
using System;
using P11_2;
namespace P11_5
{
public class BiLinkNode<T> : LinkNode<T>
{
protected BiLinkNode<T> previous;
protected new BiLinkNode<T> next;
public BiLinkNode<T> Previous // 获取或设置节点的前一个节点
{
get { return previous; }
set
{
previous = value;
if (previous != null && previous.Next != this)
previous.Next = this;
}
}
public new BiLinkNode<T> Next // 获取或设置节点的下一个节点
{
get { return next; }
set
{
next = value;
if (next != null && next.Next != this)
next.previous = this;
}
}
public BiLinkNode(T t) : base(t) { }
public static BiLinkNode<T> operator <<(BiLinkNode<T> node, int n) //移至node的第n个前驱节点
{
BiLinkNode<T> node1 = node;
for (int i = 0; i < n && node1 != null; i++)
node1 = node1.previous;
return node1;
}
}
}
------解决思路----------------------
不是写得很清楚了吗?
你用它来启动就报这个错误。
------解决思路----------------------
异常报的是没有main方法,如果你是控制台,那就在program.cs里写个static main方法,如果是winform,那就在program.cs里加上[STAThread]
static void Main()
不过话说这些不都是vs创建时默认存在的么?
------解决思路----------------------
你这个错误和神马泛型继承,没神马关系啊。
你的代码么有程序启动入口(静态Main方法)
using System;
using P11_2;
namespace P11_5
{
public class BiLinkNode<T> : LinkNode<T>
{
protected BiLinkNode<T> previous;
protected new BiLinkNode<T> next;
public BiLinkNode<T> Previous // 获取或设置节点的前一个节点
{
get { return previous; }
set
{
previous = value;
if (previous != null && previous.Next != this)
previous.Next = this;
}
}
public new BiLinkNode<T> Next // 获取或设置节点的下一个节点
{
get { return next; }
set
{
next = value;
if (next != null && next.Next != this)
next.previous = this;
}
}
public BiLinkNode(T t) : base(t) { }
public static BiLinkNode<T> operator <<(BiLinkNode<T> node, int n) //移至node的第n个前驱节点
{
BiLinkNode<T> node1 = node;
for (int i = 0; i < n && node1 != null; i++)
node1 = node1.previous;
return node1;
}
}
}
下面上引用的P11_2的源代码
using System;
using P11_2;
namespace P11_5
{
public class BiLinkNode<T> : LinkNode<T>
{
protected BiLinkNode<T> previous;
protected new BiLinkNode<T> next;
public BiLinkNode<T> Previous // 获取或设置节点的前一个节点
{
get { return previous; }
set
{
previous = value;
if (previous != null && previous.Next != this)
previous.Next = this;
}
}
public new BiLinkNode<T> Next // 获取或设置节点的下一个节点
{
get { return next; }
set
{
next = value;
if (next != null && next.Next != this)
next.previous = this;
}
}
public BiLinkNode(T t) : base(t) { }
public static BiLinkNode<T> operator <<(BiLinkNode<T> node, int n) //移至node的第n个前驱节点
{
BiLinkNode<T> node1 = node;
for (int i = 0; i < n && node1 != null; i++)
node1 = node1.previous;
return node1;
}
}
}
------解决思路----------------------
不是写得很清楚了吗?
你用它来启动就报这个错误。
------解决思路----------------------
异常报的是没有main方法,如果你是控制台,那就在program.cs里写个static main方法,如果是winform,那就在program.cs里加上[STAThread]
static void Main()
不过话说这些不都是vs创建时默认存在的么?
------解决思路----------------------
你这个错误和神马泛型继承,没神马关系啊。
你的代码么有程序启动入口(静态Main方法)