電話帳を作ることになっていたので、宿題に困っています。条件は、次のようになっていることです。
Class Phonebook
{
private List<Entry> _phoneList;
public Phonebook()
{
//instance of _phoneList
}
public void AddEntry (string name, string number)
{
//logic
}
public string FindEntry (string namne)
{
//logic
}
}
class Entry
{
public string Name{ get; private set; }
public string Number{ get; private set; }
}
AddEntry
ただし、メソッドにエントリリストに新しい名前/番号を割り当てる方法がわかりません_phoneList
。私はたくさん試しましたが、役に立ちませんでした。それを機能させるためのヒントはありますか?どんな助けでも大歓迎です!
これまでの私のコードは次のようになります
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace app3
{
public partial class Form1 : Form
{
private Phonebook phonebook;
public Form1()
{
InitializeComponent();
phonebook = new Phonebook();
}
private void addEntryButton_Click(object sender, EventArgs e)
{
phonebook.AddEntry((addNameTextBox.Text), (addNumberTextBox.Text));
}
}
class Phonebook
{
private List<Entry> _phoneList;
public Phonebook()
{
List<Entry> _phoneList = new List<Entry>();
}
public void AddEntry(string name, string number)
{
}
}
class Entry
{
public string Name { get; private set; }
public string Number { get; private set; }
}
}