473,394 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

find index value of foreach

what should i have to write in this code section?

#### is what i want to write

do i have to use foreach to for

if options is TextBox array

i used to enumbera....... but i don't remember...what is this??
foreach (TextBox option in options)
{
if (option.Text.Length > 0)
{
int poll = kkk[ ##### ].PollId;
}
}
Nov 20 '05 #1
8 1657
Use a traditional for loop.

-Brock
DevelopMentor
http://staff.develop.com/ballen
what should i have to write in this code section?

#### is what i want to write

do i have to use foreach to for

if options is TextBox array

i used to enumbera....... but i don't remember...what is this??

foreach (TextBox option in options)
{
if (option.Text.Length > 0)
{
int poll = kkk[ ##### ].PollId;
}
}

Nov 20 '05 #2
you mean like this??

int j=0;
foreach (TextBox option in options)
{
int poll = optionList[j].PollId;
j++;
}
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
Use a traditional for loop.

-Brock
DevelopMentor
http://staff.develop.com/ballen
what should i have to write in this code section?

#### is what i want to write

do i have to use foreach to for

if options is TextBox array

i used to enumbera....... but i don't remember...what is this??

foreach (TextBox option in options)
{
if (option.Text.Length > 0)
{
int poll = kkk[ ##### ].PollId;
}
}


Nov 20 '05 #3
On Sat, 19 Nov 2005 01:32:27 +0900, mike wrote:
what should i have to write in this code section?

#### is what i want to write

do i have to use foreach to for

if options is TextBox array

i used to enumbera....... but i don't remember...what is this??
foreach (TextBox option in options)
{
if (option.Text.Length > 0)
{
int poll = kkk[ ##### ].PollId;
}
}

Go back to basics a bit. Please look up
http://www.ondotnet.com/pub/a/dotnet...t&x-maxdepth=0
by Jesse Liberty.
Nov 20 '05 #4
No, like this:

for (int i = 0; i < options.Length; i++)
{
int poll = optionList[j].PollId;
}

-Brock
DevelopMentor
http://staff.develop.com/ballen
you mean like this??

int j=0;
foreach (TextBox option in options)
{
int poll = optionList[j].PollId;
j++;
}
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
Use a traditional for loop.

-Brock
DevelopMentor
http://staff.develop.com/ballen
what should i have to write in this code section?

#### is what i want to write

do i have to use foreach to for

if options is TextBox array

i used to enumbera....... but i don't remember...what is this??

foreach (TextBox option in options)
{
if (option.Text.Length > 0)
{
int poll = kkk[ ##### ].PollId;
}
}

Nov 20 '05 #5
I don't like FORRRRRRRRRRRRRRRRRRRRRR
I really wanna using FOREACH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
No, like this:

for (int i = 0; i < options.Length; i++)
{
int poll = optionList[j].PollId;
}

-Brock
DevelopMentor
http://staff.develop.com/ballen
you mean like this??

int j=0;
foreach (TextBox option in options)
{
int poll = optionList[j].PollId;
j++;
}
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
Use a traditional for loop.

-Brock
DevelopMentor
http://staff.develop.com/ballen
what should i have to write in this code section?

#### is what i want to write

do i have to use foreach to for

if options is TextBox array

i used to enumbera....... but i don't remember...what is this??

foreach (TextBox option in options)
{
if (option.Text.Length > 0)
{
int poll = kkk[ ##### ].PollId;
}
}


Nov 20 '05 #6
Unfortunately the IEnumerator interface that is used for the foreach only
provides the methods Current, MoveNext and Reset. Without knowing what the
options object is I can only assume it implements the following:

int poll = kk[ options.IndexOf(option) ].PollId;

This actually iterates through the list testing the equality using
object.Equals(object2) in which case it may be just as quick to use a for
loop:

<ObjectItem> option;

for(int i = 0; i < options.Count; i++)

{

option = options.Item[i];

if(option.Text.Length >0)

{

int poll = kk[i].PollId;

}

}

Setting the option var is optional in this case just depends on how much you
want to access the object and if your happy typecasting.

- Mike

---------------------------------------------------------------------------------
<a href="http://www.cogitar.net"> Cogitar Software. (www.cogitar.net) </a>
http://www.web-dominion.co.uk Web-Dominion. (Web Design and hosting )
---------------------------------------------------------------------------------

"mike" <so**********@gmail.com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
what should i have to write in this code section?

#### is what i want to write

do i have to use foreach to for

if options is TextBox array

i used to enumbera....... but i don't remember...what is this??
foreach (TextBox option in options)
{
if (option.Text.Length > 0)
{
int poll = kkk[ ##### ].PollId;
}
}

Nov 20 '05 #7
Sorry. If you don't like the for loop, then the the way you suggested will
work fine.

*shrug*

-Brock
DevelopMentor
http://staff.develop.com/ballen
I don't like FORRRRRRRRRRRRRRRRRRRRRR
I really wanna using FOREACH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
No, like this:

for (int i = 0; i < options.Length; i++)
{
int poll = optionList[j].PollId;
}
-Brock
DevelopMentor
http://staff.develop.com/ballen
you mean like this??

int j=0;
foreach (TextBox option in options)
{
int poll = optionList[j].PollId;
j++;
}
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
Use a traditional for loop.

-Brock
DevelopMentor
http://staff.develop.com/ballen
> what should i have to write in this code section?
>
> #### is what i want to write
>
> do i have to use foreach to for
>
> if options is TextBox array
>
> i used to enumbera....... but i don't remember...what is this??
>
> foreach (TextBox option in options)
> {
> if (option.Text.Length > 0)
> {
> int poll = kkk[ ##### ].PollId;
> }
> }

Nov 20 '05 #8
hahaha

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
Sorry. If you don't like the for loop, then the the way you suggested will
work fine.

*shrug*

-Brock
DevelopMentor
http://staff.develop.com/ballen
I don't like FORRRRRRRRRRRRRRRRRRRRRR
I really wanna using FOREACH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
No, like this:

for (int i = 0; i < options.Length; i++)
{
int poll = optionList[j].PollId;
}
-Brock
DevelopMentor
http://staff.develop.com/ballen
you mean like this??

int j=0;
foreach (TextBox option in options)
{
int poll = optionList[j].PollId;
j++;
}
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
> Use a traditional for loop.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>> what should i have to write in this code section?
>>
>> #### is what i want to write
>>
>> do i have to use foreach to for
>>
>> if options is TextBox array
>>
>> i used to enumbera....... but i don't remember...what is this??
>>
>> foreach (TextBox option in options)
>> {
>> if (option.Text.Length > 0)
>> {
>> int poll = kkk[ ##### ].PollId;
>> }
>> }


Nov 20 '05 #9

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

Similar topics

1
by: Dan Jones | last post by:
I'm writing a script to process a directory tree of images.  In each directory, I need to process each image and generate an HTML file listing all of the images and links to the subdirectories....
0
by: Popoxinhxan | last post by:
Hi guy , i would like to have a Find search function like in Ms Excel to search for specific keyword in the list view. Could anyone help me to do so. Currently i can only get the index of the item...
4
by: Arjen | last post by:
Hi, I need to add this inside an array: 1 3 2 4 3 2 4 5 5 1 I think of using this:
3
by: Earl Teigrob | last post by:
I want to write a function where I pass in a reference to a dropdownlist and a "match value" and have it returns the index of the dropdownlist item that matchs (or -1 if there is no match) ...
0
by: ssims | last post by:
I've got a GridView that's sorted by a stored procedure with ROW_NUMBER: PROCEDURE dbo.GetCalendarsByStatusIDPaged ( @startRowIndex int, @maximumRows int, @statusID int ) AS
4
by: e_matthes | last post by:
Hello everyone, I have no trouble looping through an array using foreach. To keep track of the index, I set a variable before the loop and increment it in the loop: $index = 0; foreach...
2
by: GS | last post by:
I want to create a dropdownlistbox in my windows form with name value pair. but I need to initialize its initial selected value to a value from database for the record. I was going to just use...
9
by: WebArchitect | last post by:
I have a text file. My text file contains lines with double quotes around it. I trying to code if a line has double quotes around it Then make it bold My code is below and it is not working....
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.