Queue.Contains

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
I know i can use .Contain to search a queue for a string. But how do you search a queue with a 2d array? I dont need to use a loop, do i?

VB.NET:
Dim a As New Queue(Of String)(10)
Dim b As New Queue(Of String())(10)
a.Enqueue("aa")
b.Enqueue({"aa","bb"})

if a.Contains("aa") then

end if
 
I tried to use the SizeLimitedCollection but how do you save it to My.Settings and retrieve it back? I tried to store it to an arraylist in settings with

VB.NET:
My.Settings.listData = New ArrayList(list)

and it seems to saved the data, but how do you get it back when the form loads?
 
If the ArrayList saved successfully then you can get it back as an ArrayList. You can then copy the data from the ArrayList to the SizeLimitedCollection. You could do that manually or you could make use of OOP again and build it into the class. You could write a constructor that took an IEnumerable(Of T) and added its items to the new collection and then create an instance like this:
VB.NET:
Dim list As New SizeLimitedCollection(Of Item)(myArrayList.Cast(Of Item)())
 
hmm it seems to save when i did this

VB.NET:
My.Settings.listData= New ArrayList(list)
My.Settings.Save()

i checked the My.Settings.listData and they were an array of .Items
But when i close the app and reopen it, My.Settings.listData is nothing again. Why is that?
It seems like it wont save the data of an array of array. Works fine if its SizeLimitedCollection(of String) but not (of Item)

Also can i load it directly like this?

VB.NET:
Dim list As New SizeLimitedCollection(Of Item) With {.MaxCount = 10}
list = CType(My.Settings.listData.ToArray.Cast(Of Item)(), SizeLimitedCollection(Of Item))
 
Last edited:
Back
Top