Am having some difficulty, I had some code that had a static helper method in C#, and now I am looking to port it to vb, but unfortunately vb doesn't seem to have a yield return operator. How do most vb developers do this, and why is there no yield return, it kind of strikes me as a bit odd since C# is going all LINQ, and the only way to tweak Linq is to use custom IEnumerables etc. Code goes something like this in C#.

public static IEnumerable<String> MyMethod(Arg arg){
        yield return myValue;
}//end method

Recommended Answers

All 3 Replies

VB has evolved to C# with somewhat different syntax.
It is also called VB.NET instead of just VB, VB4-5-6 or VBA.
So yield exists. See here.

commented: Thanks ddanbe! +3

Ok, so the keyword I was missing was that it actually needs to have the "Iterator" Keyword. I had actually looked at that page, and I completely missed that nuance the first time. Thanks ddanbe!

Glad to be of help.
Overlooking something happens to me all the time. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.