Hello, I got question about an assignment that I've been working on for weeks.
class ContactManager
{
public List<Contact> m_contactRegistry; //declare object of the collection
public ContactManager()
{
m_contactRegistry = new List<Contact>();
}
/// <summary>
/// returns the count of m_contactRegistry
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public Contact GetContact(int index)
{
if (index < 0 || index >= m_contactRegistry.Count)
return null;
return m_contactRegistry[index];
}
Form.cs:
private void dltButton_Click(object sender, EventArgs e)
{
string currContact;
try { currContact = listBox.SelectedItem.ToString(); }
catch (Exception) { return; }
foreach (ContactFiles.Contact c in m_contactMngr.m_contactRegistry)
{
if (c.ToString() == currContact)
{
m_contactMngr.m_contactRegistry.Remove(c);
break;
}
}
Thank you