[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 818
  • Last Modified:

Is there a VB.net equivalent to the C# yield keyword?

Is there a VB.net equivalent to the C# yield keyword?
0
MDKIMZEY
Asked:
MDKIMZEY
  • 2
3 Solutions
 
Carl TawnSystems and Integration DeveloperCommented:
The simple answer is no. But here is an example of how you can achieve the same result with VB: http://weblogs.asp.net/jgaylord/archive/2007/10/17/vb-net-s-quot-yield-return-quot.aspx
0
 
aibusinesssolutionsCommented:
0
 
aibusinesssolutionsCommented:
Or you could do something like this
Public Function GenerateData() As IEnumerable(Of IDictionary) 
    Dim list As New List(Of IDictionary)() 
    For i As Integer = 0 To 9 
        Dim dict As IDictionary = New Dictionary(Of String, Object)() 
        dict("ID") = Guid.NewGuid()
        dict("Name") = "Name_" & i.ToString()
        dict("Index") = i
        dict("IsEven") = (i Mod 2 = 0)
        list.Add(dict) 
    Next 
    Return list 
End Function

Open in new window

0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now