Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 376391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:35:40+00:00 2026-05-12T14:35:40+00:00

Guys, I’m trying to convert something from C# to VB.NET and I’m having trouble

  • 0

Guys, I’m trying to convert something from C# to VB.NET and I’m having trouble finding an equivlent in VB.NET to C#’s yield keyword. I realize ‘yield’ is not a convertable keyword to VB.NET, so can someone please show me how I would implement this code in VB.NET. I got all of it converted over except for the implemented GetEnumerator() function. It is simply a class that implements CollectionBase and IEnumerable (to make it LINQ worthy):

[Serializable()]
public partial class Customers : CollectionBase,    System.Collections.Generic.IEnumerable<BusinessLayer.Customer> 
{

    public new System.Collections.Generic.IEnumerator<BusinessLayer.Customer> GetEnumerator()
    {
        foreach (BusinessLayer.Customer Cust in this.List)
        {
            yield return Cust;
        }
    }

    public Customers()
    {

    }

    public Customers(DataRowCollection datarows) : this()
    {
        this.Load(datarows);
    }
    protected void Load(DataRowCollection dataRows)
{
    foreach (DataRow dr in dataRows) {
        this.Add(new Customer(dr));
    }
}

public Customer this[int index] {
    get { return (Customer)base.InnerList[index]; }
    set { base.InnerList[index] = value; }
}

public int Add(Customer val)
{
    return base.InnerList.Add(val);
}
}

Thanks in advance for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:35:40+00:00Added an answer on May 12, 2026 at 2:35 pm

    Because you cannot use the yield keyword, you will have to implement GetEnumerator() another way. What you can do is return the enumerator of the List from CollectionBase. However, because this is an IList and not an IList<T>, you will have to cast it (you can use the Cast<T>() extension method from Linq for this). Your C# code then becomes:

    public IEnumerator<BusinessLayer.Customer> GetEnumerator()
    {
        return InnerList.Cast<BusinessLayer.Customer>().GetEnumerator();
    }
    

    This gives the same result, but behaves in a slightly different way (with regards to no longer using the delayed execution of yield).

    In VB.Net, GetEnumerator() would be:

    Public Function GetEnumerator() As IEnumerator(Of BusinessLayer.Customer)
        Return InnerList.Cast(Of BusinessLayer.Customer)().GetEnumerator()
    End Function
    

    The rest of your code should translate directly to VB.Net.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

guys, I'm trying to realize viewing comments on internet portal and I'm using UITableView.
Guys I have been trying lots of different options from cutting up to building
Guys, this can't be for real I'm trying to make a .NET 2.0 executable
Guys, for some reason EL is not telling actions from properties. I have this
Guys that is code copied from a book (Programming Windows 5th edition): #include <windows.h>
Guys, I'm trying to write xpath or css to find/click on list element All
Guys, Is there an easy way to return different fields names from different models
Guys i am trying to connect my android app to php server and using
guys, I have the problem when copying database from local assets folder to /data/data/package_name/databases
Guys im trying to check/uncheck a checkbox based on the state check/uncheck of another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.