Is there a equivalent to the C# yield keyword?

Posted on 2009-02-20
Last Modified: 2012-05-06
Is there a equivalent to the C# yield keyword?
Question by:MDKIMZEY
    LVL 52

    Assisted Solution

    by:Carl Tawn
    The simple answer is no. But here is an example of how you can achieve the same result with VB:
    LVL 15

    Accepted Solution

    LVL 15

    Assisted Solution

    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)
        Return list 
    End Function

    Open in new window


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now