473,890 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Yield Keyword in VB.NET 2.0

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
----------------------------------------------------------------------------
Nov 21 '05
54 6951
Cor,

"Cor Ligthert" <no************ @planet.nl> schrieb:
I only tried to give Sahil an alternative for his 'yield'.
As I say, your sample is /not/ an alternative.
The static is the one that comes in my idea the most near at it.
It doesn't. Take a look at the C# sample I posted in the other reply.
And than I got reply that was in my opinion about a shared class and his
members.

I am quiet sure that the yield is not exactly the same as a VB static,
otherwise I had given an example with a foreach.

Although in my idea is it not imposible that it will act internal not much
less than a VB static variable. You cannot keep values in memory and in
the same time let them go out of scope.


Static variables in VB.NET won't help much. The trick behind the 'yield' is
that it returns the value to the iterator but doesn't exit the method. This
behavior can be faked using delegates, as mentioned in another reply.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #31
"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> schrieb:
I just wanted to explain that code like you wrote is hard to read,
thus not what you want. This was mainly caused by the static keyword.
I.o.w.: static is IMHO a keyword you should better avoid (like goto),


I disagree. There are certain cases where 'Static' makes perfect sense and
additionally leads to better-encapsulated code than using a private (shared)
field. Note that this should not encourage the use of 'Static' where it
doesn't make much sense ;-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #32
"Cor Ligthert" <no************ @planet.nl> schrieb:
Frans is completely right in this regard. I asked you about yield, you
are telling me about static/shared -


Maybe it is wise that you buy this book before you go on in that one that
you are endless telling in these newsgroup that you are writting now.

http://www.nbcindia.com/Descriptions.asp?title_id=2545


Cor, try to keep it outside the groups.

"A real man can admit when he makes a mistake."

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #33
Maybe a feeble attempt at humor will ligthen things up. My buddy Roland
once gave me this expression and I loved it becuase, well, it's practically
my personal motto "
Doe maar gewoon, dan doe je al gek genoeg"

http://rolandboon.net/WSBeanRSS/Webl...y=2004-12-30/1

This is probably a good time for us all to listen to good old Roland ;-)

Also , remind me to tell you about our discussion after the user's group
about business objects.
--
W.G. Ryan, MVP
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Sahil Malik [MVP]" <co************ *****@nospam.co m> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
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
----------------------------------------------------------------------------

Nov 21 '05 #34
Herfried,

As I said, I have to little information about the yield. I gave my answer as
a maybe equivalent of it.

Where I wrote "I think that this reaches where you are looking for".

The answer on this message was
\\\
I'm not talking about "Static/Shared" .. I am talking about "Yield".
///

This answer could have been as well in a decent way, however it gave me the
idea that the OP did/does (still) not know what static means VB as special
keyword inside a procedure. Therefore I tried to explain it by samples.

You always learns in these newsgroup.

:-))

Cor

Nov 21 '05 #35
Herfried,

Cor, try to keep it outside the groups.
As you know I try forever, however sometimes I get angry when the mud is to
much.
However you are right in this one.

If you look at the last replies from Frans than you see what I tried to
tell.
(The one you have replied now that you disagreed. And do that than because
of that as well with me).
"A real man can admit when he makes a mistake."

I am not mistaking in this. In my opinion have I nowhere written what you
probably think that you read from the answers from others.

See my other message to your thread written before I could read this one.

Cor

Nov 21 '05 #36
Bill,
Doe maar gewoon, dan doe je al gek genoeg"

I have the idea, if Frans tell that I am not than I will agree.

Dit slaat als een tang op een varken.

:-)))

Cor
Nov 21 '05 #37
Herfried K. Wagner [MVP] wrote:
"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> schrieb:
I just wanted to explain that code like you wrote is hard to read,
thus not what you want. This was mainly caused by the static
keyword. I.o.w.: static is IMHO a keyword you should better avoid
(like goto),


I disagree. There are certain cases where 'Static' makes perfect
sense and additionally leads to better-encapsulated code than using a
private (shared) field. Note that this should not encourage the use
of 'Static' where it doesn't make much sense ;-).


Now I'm interested in what these situations are. Could you give an
explanation where it will give much BETTER code than when you wouldn't
have the Static keyword?

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#)
------------------------------------------------------------------------
Nov 21 '05 #38
I actually got that phrase from Rolan Boon. I have a LONG way to go
learning Dutch before I make it over there at the end of the year.

Mijn Nederlands is slecht, maar ik denk ik begrijp
What I was hoping to say is that My dutch isn't all that good, but I think I
understood your point.
--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Bill,
Doe maar gewoon, dan doe je al gek genoeg"

I have the idea, if Frans tell that I am not than I will agree.

Dit slaat als een tang op een varken.

:-)))

Cor

Nov 21 '05 #39
Cor Ligthert wrote:
Bill,
Doe maar gewoon, dan doe je al gek genoeg"
I have the idea, if Frans tell that I am not than I will agree.


wat is dit voor steenkolen-engels, man :)
Dit slaat als een tang op een varken.


indeed :)

FB
Nov 21 '05 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
2739
by: Sahil Malik [MVP] | last post by:
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 Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync ----------------------------------------------------------------------------
3
6942
by: Ehsan | last post by:
hi coulde any one show me the usage of "yield" keyword specially in this example: """Fibonacci sequences using generators This program is part of "Dive Into Python", a free Python book for experienced programmers. Visit http://diveintopython.org/ for the latest version.
0
9970
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11207
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10896
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7153
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5830
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6031
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.