473,804 Members | 3,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# equivalent of VB.NET "For Each"

What is the C# equivalent to the VB.Net looping structure:

Protected rbl As RadioButtonList

Dim li As ListItem
For Each li In rbl.Items

Next li
Nov 16 '05 #1
17 4726
Believe it or not, it's called "foreach".

"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:eF******** ******@TK2MSFTN GP15.phx.gbl...
What is the C# equivalent to the VB.Net looping structure:

Protected rbl As RadioButtonList

Dim li As ListItem
For Each li In rbl.Items

Next li

Nov 16 '05 #2
C# has foreach as well:

http://msdn.microsoft.com/library/de...us/csref/html/
vclrfTheForeach Statement.asp

Any class that implements IEnumerable will support foreach.

--
Ajay Kalra [MVP - VC++]
aj*******@yahoo .com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:eF******** ******@TK2MSFTN GP15.phx.gbl...
What is the C# equivalent to the VB.Net looping structure:

Protected rbl As RadioButtonList

Dim li As ListItem
For Each li In rbl.Items

Next li

Nov 16 '05 #3
On Mon, 21 Mar 2005 21:38:47 -0500, Ajay Kalra wrote:
Any class that implements IEnumerable will support foreach.


Actually any class with a public GetEnumerator() method that returns an
IEnumerator implementation will support foreach. The class doesn't need to
implement IEnumerable, just have the GetEnumerator() method. There are
times when this subtle difference can be important.
--
Tom Porterfield
Nov 16 '05 #4
RTFM

On Mon, 21 Mar 2005 18:19:38 -0800, "John Grandy"
<johnagrandy-at-yahoo-dot-com> wrote:
What is the C# equivalent to the VB.Net looping structure:

Protected rbl As RadioButtonList

Dim li As ListItem
For Each li In rbl.Items

Next li


Nov 17 '05 #5
Thank you for your very positive statement regarding profesionalism,
camaraderie, the planet, and those who live on it.

"QWERTY" <no@email.com > wrote in message
news:5m******** *************** *********@4ax.c om...
RTFM

On Mon, 21 Mar 2005 18:19:38 -0800, "John Grandy"
<johnagrandy-at-yahoo-dot-com> wrote:
What is the C# equivalent to the VB.Net looping structure:

Protected rbl As RadioButtonList

Dim li As ListItem
For Each li In rbl.Items

Next li

Nov 17 '05 #6

"QWERTY" <no@email.com > wrote in message
news:5m******** *************** *********@4ax.c om...
RTFM


He can't look up the statements of one language in the manual of another
language. See the problem? There is no specific "FM" that answers his
question.
Nov 17 '05 #7

Actually there is.

Language Equivalents
http://msdn.microsoft.com/library/de...quivalents.asp

Sam
On Tue, 22 Mar 2005 12:50:59 -0500, "Michael A. Covington"
<lo**@ai.uga.ed u.for.address> wrote:

"QWERTY" <no@email.com > wrote in message
news:5m******* *************** **********@4ax. com...
RTFM


He can't look up the statements of one language in the manual of another
language. See the problem? There is no specific "FM" that answers his
question.


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 17 '05 #8
Yes yes yes I could have looked it up. But what I never understood about
the "RTFM" people is that it takes them longer to type and submit a "RTFM"
answer than it takes them to read the question in the first place, so if
they are so annoyed by their time being wasted by "obvious questions" then
why do they invest the additional time to respond?

"Samuel R. Neff" <bl****@newsgro up.nospam> wrote in message
news:77******** *************** *********@4ax.c om...

Actually there is.

Language Equivalents
http://msdn.microsoft.com/library/de...quivalents.asp

Sam
On Tue, 22 Mar 2005 12:50:59 -0500, "Michael A. Covington"
<lo**@ai.uga.ed u.for.address> wrote:

"QWERTY" <no@email.com > wrote in message
news:5m****** *************** ***********@4ax .com...
RTFM


He can't look up the statements of one language in the manual of another
language. See the problem? There is no specific "FM" that answers his
question.


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.

Nov 17 '05 #9

Because once you get a "how do you do for-each in c#" then you get
"how do you do x" and "how do you do y" and on and on and on.

Looking up answers instead of just posting questions is very
beneficial in that you not only get the answer to your question but
almost always end up learning something else unrelated.

Sam
On Tue, 22 Mar 2005 10:32:42 -0800, "John Grandy"
<johnagrandy-at-yahoo-dot-com> wrote:
Yes yes yes I could have looked it up. But what I never understood about
the "RTFM" people is that it takes them longer to type and submit a "RTFM"
answer than it takes them to read the question in the first place, so if
they are so annoyed by their time being wasted by "obvious questions" then
why do they invest the additional time to respond?

"Samuel R. Neff" <bl****@newsgro up.nospam> wrote in message
news:77******* *************** **********@4ax. com...

Actually there is.

Language Equivalents
http://msdn.microsoft.com/library/de...quivalents.asp

Sam


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 17 '05 #10

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

Similar topics

0
2479
by: Eric Wichterich | last post by:
Hello Pythonistas, does anyone know an equivalent python statement for perl's "next"-statement? (Perl's "next" skips a loop cycle and continues with the next loop cycle - it does not abort the whole loop). Thank you! Eric
8
1781
by: lancevictor | last post by:
I'm learning javascript, and toward that end, I am recreating a page "my way". The original page: http://stenbergcollege.com and the one that I'm creating: http://www3.telus.net/neustaeter/Stenberg When I added the buttons manually, everything was hunky-dory and it looked pretty much exactly like the original page. When I changed the script so that it uses the for loop to insert the top row of buttons, space seems to get inserted...
3
19479
by: Martin | last post by:
Hello everybody, I have the following question. As a join clause on Oracle we use " table1.field1 = table2.field1 (+) " On SQL Server we use " table1.field1 *= table2.field1 " Does DB2 have the same type of operator, without using the OUTER JOIN syntax ?
3
18267
by: Summit | last post by:
Does anyone know what the C# equivalent for VB6 End is? I'm starting up a form with a boolean test. If I fail, I just want to end the app. Even though I close the form, it picks up on the line after the bracket and continues loading the form. Here's my snippet: DalMan._drCurrentUser = DalMan._dtUsers.FindByUserName("Init"); if (DalMan._drCurrentUser == null)
5
1827
by: TomislaW | last post by:
What is asp.net equivalent for Application("Root") in asp?
11
1800
by: .Net Sports | last post by:
I need to convert some C# ?Conditionals over to vb.net (most likely in vb.net using If..Then statements), but the C#2VBNETconverter by KamalPatel isn't converting them: string PurchaseType = (Convert.ToString(drwData) == "True") ? "ID" : "PID"; XmlNodeList Selections = xdcData.GetElementsByTagName((X == 0) ? "Highlight" : "Selection");
2
12200
by: Tasman | last post by:
Is there an equivalent of valign="bottom" for a table within a DIV using CSS? I've found I can center a table of buttons in a DIV with {margin-left:auto; margin-right:auto}. But I am unsure how to get this table to sit at the bottom of the DIV. Example code follows, or see http://home.exetel.com.au/tas/valign/test01.html
43
3184
by: Christoph Schneegans | last post by:
Hi! Okay, so positions on "text/html" XHTML are totally contradicting. Anyway! I hope there's more consensus about "application/xml" XHTML. I've recently learned that Opera 9.0b2 does not only evaluate HTTP header, BOM and XML declaration to determine the character encoding of an XHTML document sent as "application/xml", but also the "meta" element. For example, <http://schneegans.de/sv/test-cases/?case=meta-only-encoding> is rendered...
2
4273
by: Big Bill | last post by:
What's the CSS equivalent for that frequently found table coding? Roughly speaking? I know that speaking of equivalents can itself lead one into a semantic nightmare but, loosely speaking, what would you guys put? BB -- http://www.kruse.co.uk/internet-marketing-small-business.htm http://www.kruse.co.uk/close-ended-questions.htm
0
9711
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
10594
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...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
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
10087
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...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5529
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
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.