I want to put all elements of a String array into a Queue(Of String). I have following code which using For…Each to put string into Queue(Of String):
Dim Files() As String = OpenFileDialog1.FileNames
'OpenFileDialog1 is an instance of OpenFileDialog control
Dim PendingFiles As New Queue(Of String)
For Each x1 As String In Files
PendingFiles.Enqueue(x1)
Next
My question: Is that possible to do it (i.e. put string array into Queue(Of String)) without using For…Each?
Use the constructor of
Queue<T>that takes anIEnumerable<T>.