471,325 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Searching ArrayList [C# WindowForms]

Hi Everyone,

I'm am trying to find the best method option for searching through an
ArrayList and getting various items at a time. It could be 0 to 14, 15 to 25
etc,etc. I wish .GetRange(0,45) would give more options than just zero base
to whatever.

Right now, (unless there is a better option) I will keep calling the
ArrayList at various times getting the 15 or less items at a time and put
the items into another ArrayList for my usage. Is looping the best method?
Any and all help is appreciated. A sample code is at follows
private void Get_ArrayList()
{
ArrayList_Load_Data myArrayList_Load_Data = new ArrayList_Load_Data();
myArrayList = myArrayList_Load_Data.Test;
ArrayList myArrayList2 = new ArrayList();

foreach(DataItem myItem in myArrayList)
{
if(myItem.Index >= 0 && myItem.Index < 14)
{
myArrayList2.Add(myItem);
}
}
foreach(DataItem myItem1 in myArrayList2)
{
MessageBox.Show(": " + myItem1.Name + myItem1.Index);
}
}.
Feb 17 '06 #1
4 3531
if its not broken, then dont fix it :)

there is probably a dozen different ways to accomplish this. You could
override .GetRange and write your own code for getting the range, or
simply loop like you are doing here.

Feb 17 '06 #2
Txs DKode,

I was just looking to see if there was a better way of getting at my data or
getting at a group of my items. I just wish GetRange would get my data items
at various point GetRange(22,26) instead of GetRange(0,26) when I really
only need the last 5 items. Txs Again

MikeY

"DKode" <dk****@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
if its not broken, then dont fix it :)

there is probably a dozen different ways to accomplish this. You could
override .GetRange and write your own code for getting the range, or
simply loop like you are doing here.

Feb 17 '06 #3
according to the msdn, the first parameter is a zero based index, which
implies that you should be able to pass any index to start at:

http://msdn2.microsoft.com/en-us/lib....getrange.aspx

Feb 17 '06 #4
Txs Again DKode,

After doing the sample at MSDN I summised that I was using the GetRange
wrong. Anyhow I am going to with your origional reply "If it ain't broke"
reply, because I would still need to know where and the amount of data
before using this method other wise I'll just end up getting the dreaded
offset length out of bound exception. Txs Again DKode.

MikeY

"DKode" <dk****@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
according to the msdn, the first parameter is a zero based index, which
implies that you should be able to pass any index to start at:

http://msdn2.microsoft.com/en-us/lib....getrange.aspx

Feb 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Randy | last post: by
4 posts views Thread by dotNetDave | last post: by
2 posts views Thread by dotNetDave | last post: by
10 posts views Thread by C Downey | last post: by
9 posts views Thread by Paul Nations | last post: by
33 posts views Thread by Geoff Jones | last post: by

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.