看板 C_Sharp 關於我們 聯絡資訊
※ 引述《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
james732:代表你那個時候的 bottom 是 null 11/01 22:33
light0617:那請問一下要怎麼改@@ 11/01 23:03