jjocan2003

There is my question, i have an array and im doing a for each to search for a specific value, and i need to get the offset value.

Code Snippet

foreach (string item in itemsarray)

{

if (item.Contains(strsearchentry))

{

offset = itemsarray ;//****get the offset of the item entry***

stradd = SendOValue(offset);

fm.listBox1.Items.Add(stradd);

}

}

how can i get the offset value let say the first if retrned one and it was in the itemsarray[3] how can i get the [3]




Re: Visual C# Language Get offset value in array?

TilakGopi

Hi,

one thing is have an integer initialzed to zero and increment it as shown below.




int ItemOffSet = 0;
foreach (string item in itemsarray)
{
if (item.Contains(strsearchentry))
{
offset = ItemOffSet; //This will give you the offset
stradd = SendOValue(offset);
fm.listBox1.Items.Add(stradd);
}
ItemOffSet++;
}


second way is




int ItemOffSet = 0;
for (;ItemOffSet<itemsarray.Length;ItemOffSet++)
{
if (itemsarray[ItemOffSet].Contains(strsearchentry))
{

offset = ItemOffSet; //This will give you the offset
stradd = SendOValue(offset);
fm.listBox1.Items.Add(stradd);
}
}


Thanks,

Ch.T.Gopi Kumar.







Re: Visual C# Language Get offset value in array?

jjocan2003

Thanks for the precious help, now i got everything sorted out and it should work fine from now on Smile keep up the good work in helping others guys, knowledge is the key to open locked door leading to the infite knowledge




Re: Visual C# Language Get offset value in array?

TilakGopi

jjocan2003 wrote:

Thanks for the precious help, now i got everything sorted out and it should work fine from now on

That's cool.

jjocan2003 wrote:

keep up the good work in helping others guys, knowledge is the key to open locked door leading to the infite knowledge

Sure ..

Thanks & Regards,

Ch.T.Gopi Kumar.