DotNet Visual Basic: Yield Keyword in VB.NET 2.0

  • sahilmalikmvp / 204 / Fri, 27 Mar 2009 20:40:00 GMT / Comments (9)
  • What the heck - I can't find it. A bit shocked to see it missing though.

    So "Does VB.NET have the yield keyword, or any equivalent of it" ?
    - Sahil Malik [MVP]
    Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync

  • Keywords:

    yield, keyword, vb.net, 2.0, dotnet, visual basic

  • http://dotnet.itags.org/dotnet-visual-basic/164/«« Last Thread - Next Thread »»
    1. Sahil,

      Please to give better posibilities to research and therefore a better
      product, use this newsgroups for Net 2.0 and related products.

      Lab
      http://lab.msdn.microsoft.com/vs2005/community/

      I hope this helps,

      Cor

      corligthert | Fri, 06 Jun 2008 11:40:00 GMT |

    2. Cor,

      I checked that place - no help there.

      I must say, I am incredibly frustrated and very annoyed that something as
      important as the "yield" keyword would be missed out of VB.NET.

      Now try writing a SQLCLR TVF and the 3 lines it takes to accomplish it in C#
      translate to 3 pages of buggy VB.NET code. Highly Highly Highly Highly
      stupid to miss that out IMO.
      - Sahil Malik [MVP]
      Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync

      "Cor Ligthert" <notmyfirstname...planet.nl> wrote in message
      news:Owr9F96dFHA.1384...TK2MSFTNGP09.phx.gbl...
      > Sahil,
      > Please to give better posibilities to research and therefore a better
      > product, use this newsgroups for Net 2.0 and related products.
      > Lab
      > http://lab.msdn.microsoft.com/vs2005/community/
      > I hope this helps,
      > Cor
      >


      sahilmalikmvp | Fri, 06 Jun 2008 11:41:00 GMT |

    3. Sahil,

      I think that this reaches where you are looking for. This old Visual Basic
      keyword is probably one of the reasons why what is in C language called
      Static is called in VBNet Shared.

      http://msdn.microsoft.com/library/de...ialization.asp

      I hope this helps,

      Cor

      corligthert | Fri, 06 Jun 2008 11:42:00 GMT |

    4. Cor,

      I'm not talking about "Static/Shared" .. I am talking about "Yield".

      - Sahil Malik [MVP]
      Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync

      "Cor Ligthert" <notmyfirstname...planet.nl> wrote in message
      news:uf7uBc7dFHA.1600...tk2msftngp13.phx.gbl...
      > Sahil,
      > I think that this reaches where you are looking for. This old Visual Basic
      > keyword is probably one of the reasons why what is in C language called
      > Static is called in VBNet Shared.
      > http://msdn.microsoft.com/library/de...ialization.asp
      > I hope this helps,
      > Cor
      >


      sahilmalikmvp | Fri, 06 Jun 2008 11:43:00 GMT |

    5. >So "Does VB.NET have the yield keyword, or any equivalent of it" ?

      No. Different languages have different features.

      Mattias
      Mattias Sjgren [MVP] mattias ... mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      mattiassjgren | Fri, 06 Jun 2008 11:44:00 GMT |

    6. Thanks Mattias. Finally a direct answer to a simple question.
      - Sahil Malik [MVP]
      Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync

      "Mattias Sjgren" <mattias.dont.want.spam...mvps.org> wrote in message
      news:uYJMHQ8dFHA.796...TK2MSFTNGP09.phx.gbl...
      > No. Different languages have different features.
      >
      > Mattias
      > --
      > Mattias Sjgren [MVP] mattias ... mvps.org
      > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      > Please reply only to the newsgroup.


      sahilmalikmvp | Fri, 06 Jun 2008 11:45:00 GMT |

    7. Sahil,

      > I'm not talking about "Static/Shared" .. I am talking about "Yield".
      >

      I assume that you do not know what Static is in VBNet, therefore I gave you
      the link to the page.

      If you want a mercedes with a chevrolet logo, than you have to put that logo
      on it yourself, Mercedes does not do that for you.

      However I find the Mercedes logo is not bad at all

      static d as integer
      For each a in b
      d += 1
      Next

      This gives you at the end of your program the total result of loops or if
      you set it conditional to zero let you go on where you was in the loop.

      I am not busy with 2005, however short reading gave me the idea that this
      was the idea.

      I hope this helps,

      Cor

      corligthert | Fri, 06 Jun 2008 11:46:00 GMT |

    8. Cor Ligthert wrote:

      > Sahil,
      > I assume that you do not know what Static is in VBNet, therefore I
      > gave you the link to the page.
      > If you want a mercedes with a chevrolet logo, than you have to put
      > that logo on it yourself, Mercedes does not do that for you.
      > However I find the Mercedes logo is not bad at all
      > static d as integer
      > For each a in b
      > d += 1
      > Next
      > This gives you at the end of your program the total result of loops
      > or if you set it conditional to zero let you go on where you was in
      > the loop.
      > I am not busy with 2005, however short reading gave me the idea that
      > this was the idea.


      yield is a keyword which is only valid in custom enumerator routines
      ('iterators'), something which is C# 2.0 only if I'm not mistaken. It's
      therefore logical VB.NET doesn't have a yield equivalent, as it doesn't
      support custom iterator creation (though it's my understanding it does
      support consuming them). At least, that's my understanding, but I might
      have overlooked something.

      Therefore, babbling about static/shared is erm... completely
      irrelevant ;)

      FB
      Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
      My .NET blog: http://weblogs.asp.net/fbouma
      Microsoft MVP (C#)

      fransboumacmvp | Fri, 06 Jun 2008 11:47:00 GMT |

    9. Sahil Malik [MVP] wrote:

      > What the heck - I can't find it. A bit shocked to see it missing
      > though.
      > So "Does VB.NET have the yield keyword, or any equivalent of it" ?


      yield is a keyword for custom iterators, which IMHO is something
      which is C# only.

      However, it's not hard to work around it. After all, we all write code
      today which works OK right?

      FB
      Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
      My .NET blog: http://weblogs.asp.net/fbouma
      Microsoft MVP (C#)

      fransboumacmvp | Fri, 06 Jun 2008 11:48:00 GMT |