我創(chuàng)建了一個通用類,這是我的代碼using System;public class Node<T>{ T data; Node<T> link; public Node(T data, Node<T> link) { this.data = data; this.link = link; } public void Write() { Console.WriteLine("Data : " + this.data , this.link); }}class Program{ static void Main() { Node<string> node1 = new Node<string>("Some", null); Node<string> node2 = new Node<string>("Thing", node1); node1.Write(); node2.Write(); //to write on the console Console.ReadKey(); }}我只是很困惑,或者我的語法真的錯了。請告訴我所以我寫了node1.Write()node2.Write()輸出應(yīng)該是節(jié)點 1一些節(jié)點2東西一些我是對還是不對??請賜教。
- 2 回答
- 0 關(guān)注
- 183 瀏覽
添加回答
舉報
0/150
提交
取消