VB 2010 has provided a great way of intilizing collections, thats helps our code to be more redable, compact etc.

 

 

Dim users As New List(Of String) From {"Jack", "Ferdinand"}

 

 

But if I type
Dim BillPayers As New Queue(Of String) From {"George", "Anthony"}
I get an instant error
System.Collections.Generic.Queue(Of String)' with a collection initializer because it does not have an accessible 'Add' method.
Wow! Thats helpful, it says we cannot use collecion intializer since Queue does not have an Add method. Now here comes extension method to rescue

 

Module

Extensions
    <Extension()> Sub Add(Of t)(ByVal InitializableQ As Queue(Of t), ByVal ToAddValue  As t)
      InitializableQ.Enqueue(ToAddValue)
      End Sub
End
Module

 

 

Voila, You are done!!

Keep testing...........