Resolved Initialize SortedList with Constructor

WebKill2k

Member
Joined
May 15, 2008
Messages
14
Programming Experience
1-3
I figured out how to do this with a list, here is the code I found:

Public Class ContactInfo
Public ClientName as String
Public ClientNumber as String
End Class

ContactNumbers = New List(Of ContactInfo)() From {
New ContactInfo with {.ClientName = "Test1", .ClientNumber = "123-456-7890"},
New ContactInfo with {.ClientName = "Test2", .ClientNumber = "234-567-8901"}
}


But I wanted a key as well, so a dictionary or sortedlist, how would I do this?


ContactNumbers = New SortedList(Of Integer, ContactInfo)() From {
New ??
}
 
Last edited:
I figured it out:

ContactNumbers = New SortedList(Of Integer, ContactInfo)() From {
{"123", New ContactInfo with {.ClientName = "Test1", .ClientNumber = "123-456-7890"}},
{"456", New ContactInfo with {.ClientName = "Test2", .ClientNumber = "234-567-8901"}}
}
 
Back
Top