-2
class Program
{
public string name;
public string cell;
public Program(string a1,string c1)
{
name = a1;
cell = c1;
}
public void DetailAccept()
{
Console.WriteLine("enter name :");
name = Console.ReadLine();
Console.WriteLine("enter cell :");
cell = Console.ReadLine();
}
public string getName()
{
return name;
}
public string getCellNo()
{ return cell; }
public void AddL(string a, string b, LinkedList<Program> linked)
{
Program p1 = new Program(a, b);
linked.AddLast(p1);
}
public void menu()
{
Console.WriteLine("\n Choose what to do :\n1. Add new Entry\n2. Search Phone\n3.quit\n");
int choice = Convert.ToInt16(Console.ReadLine());
switch(choice)
{
case 1: DetailAccept();
AddL(getName(), getCellNo(), linked); // here is the problem .
}
}
}
我是否需要通過LinkedList
作爲參數才能在函數中使用它?如果是,那麼如果不是,那麼如何選擇?如何將鏈接列表作爲參數傳遞給方法以及如何調用它?
看來你已經有一些代碼。它有什麼問題? – 2014-09-24 14:59:52
實例字段,屬性? – 2014-09-24 15:02:23