我无法从我的列表(联系人)中删除对象
以下是我的字段:
Public Class Contact
'Things to remember
Private m_firstName As String = String.Empty
Private m_lastName As String = String.Empty
Private m_address As Address
我的清单:
Public Class ContactManager
Private m_contactRegistry As List(Of Contact)
Public Sub New()
m_contactRegistry = New List(Of Contact)()
End Sub
我在ContactManger类中的方法。 这里我收到错误“类型'整数'的值无法转换为索引上的Assignment.Contact”
Public Function DeleteContact(index As Integer) As Boolean
m_contactRegistry.Remove(index)
Return True
End Function
我的Main类上的删除按钮方法:
Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click
'listResults is my listbox
Dim list = listResults.SelectedIndex
'm_contact is an object of the Contact class
m_contacts.DeleteContact(list)
UpdateGUI()
End Sub
问题是我不知道如何使用DeleteContact(index As Integer)方法而不会出现错误。你们有什么建议吗?