Finally Visual Basic Dot Net supports Yield statement.
Really, I'm glad Finally Visual Basic Dot Net supports Yield statement.
No more pain with Custom Collection.
1- Start a windows Form Project
2- Add ListBox control to the Form
3- Use the code as follows
Public Class Form1
Private ColorCollection As ICollection(Of KnownColor) = New List(Of KnownColor) From {KnownColor.Aqua, KnownColor.Red, KnownColor.Black}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each clr As KnownColor In KnowncolorItreator()
ListBox1.Items.Add(clr)
Next
End Sub
Public Iterator Function KnowncolorItreator() As IEnumerable(Of KnownColor)
For Each clr As KnownColor In ColorCollection
Yield clr
Next
End Function
End Class
No more pain with Custom Collection.
1- Start a windows Form Project
2- Add ListBox control to the Form
3- Use the code as follows
Public Class Form1
Private ColorCollection As ICollection(Of KnownColor) = New List(Of KnownColor) From {KnownColor.Aqua, KnownColor.Red, KnownColor.Black}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each clr As KnownColor In KnowncolorItreator()
ListBox1.Items.Add(clr)
Next
End Sub
Public Iterator Function KnowncolorItreator() As IEnumerable(Of KnownColor)
For Each clr As KnownColor In ColorCollection
Yield clr
Next
End Function
End Class
Comments
Post a Comment