作者light0617 (遗忘的~光)
看板C_Sharp
标题Re: [问题] C# null
时间Sun Nov 1 21:50:53 2009
※ 引述《light0617 (遗忘的~光)》之铭言:
: 在C++中常常看到
: 链结串列最後面的一个都接上NULL
: 可是C#好像不能这样用
: 请问C#中的NULL要改成什麽才能代表结束的意思
: 例如
: while (walk != null)
: {
: Console.WriteLine(walk.num);
: walk = walk.next;
: }
: 我想让walk 一直执行直到结束
: 有什麽方法??
: 还有
: 我设定bottom.next = Null;
: bottom为最後一个
: c#不能接上NULL
: 那可以怎麽做
: 请教各位大大们
: 感恩~~~
未处理的例外状况 System.NullReferenceException:并未将物件参考设定为物件的
的执行个体
请为各位大大
这是什麽意思
我的类别
class box
{
public box() { }
public char num;
public box next;
}
然後主程式
char[] list = new char[10] { 'a', 'b', 'j', 'k', 't', 'n', 'l', 'u', 'b', 'v'
};
box top = new box { };
box walk = new box { };
box bottom= new box { };
top.num = list[0];
walk = top;
for (int i = 1; i < 10; i++)
{
bottom.num = list[i];----------->他说问题在这
bottom.next =null;
walk = bottom;
bottom = bottom.next;
}
这是撷取一段...
小弟实在不知那段文字是什麽意思QQ
请教各位大大大罗!!!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.119.136.4
1F:→ james732:代表你那个时候的 bottom 是 null 11/01 22:33
2F:→ light0617:那请问一下要怎麽改@@ 11/01 23:03