473,386 Members | 1,766 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,386 software developers and data experts.

Accessing Arraylists

Hello,

ArrayList arrTestArrayList =
TestArrayList.LoadTestRecords(ConnectionString,Sta rtDate,EndDate);

and it is in the same public class and namespace that I am trying to
access it from. Basically, I am looking for a way to test against the
value at position 6 in that arraylist like:

If (x = valueAtArrayList[6])
{
Do Something;
}

Any help on this would be greatly appreciated. Thank you!

DH
*** Sent via Developersdex http://www.developersdex.com ***
Mar 23 '06 #1
5 1116
Hi,

What is the error you are getting?

I think you used the assignment operator = instead of the comparision
operator ==
Also remember that you are getting an object reference, so you need to cast
it to the type of "x" variable:

int x=1;
if ( x == (int) arrTestArrayList [5] )

Also as ArrayList start at index 0 the 6th element is at position 5
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dogmar Hoffman" <it******@itbranch.com> wrote in message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
Hello,

ArrayList arrTestArrayList =
TestArrayList.LoadTestRecords(ConnectionString,Sta rtDate,EndDate);

and it is in the same public class and namespace that I am trying to
access it from. Basically, I am looking for a way to test against the
value at position 6 in that arraylist like:

If (x = valueAtArrayList[6])
{
Do Something;
}

Any help on this would be greatly appreciated. Thank you!

DH
*** Sent via Developersdex http://www.developersdex.com ***

Mar 23 '06 #2
Actually, a better representation is:

public int one(string conn,DateTime start,DateTime end)
{
try
{
ArrayList arrTestArrayList =
TestArrayList.LoadTestRecords(ConnectionString,Sta rtDate,EndDate);

foreach(thing something in anything)
{
something.Load(arrTestArrayList);
}
}
return 1;
}

public int GetStuff()
{
try
{
If (x = value in TestArrayList[6])
{
Do Something;
}
}
}

So in GetStuff, I would like to be able to get the values from
TestArrayList. Thank you very much and I hope that this is clearer.

DH

*** Sent via Developersdex http://www.developersdex.com ***
Mar 23 '06 #3
What does the LoadTestRecords method do? What exactly is getting
loaded into the arraylist? Strings? Integers? Instances of some
class?

If the items in the arraylist are strings then you would use:

if (x == arrTestArrayList[6].ToString())

If the items are integers:

if (x == (int)arrTestArrayList[6])

If they are instances of some class and you are comparing a single
property:

MyClassName m = (MyClassName) arrTestArray[6];
if (x == m.SomeProperty)
So it depends on what the items in the arraylist are. You must cast
the object to the appropriate type.

Mar 23 '06 #4
The error that I am getting is that arrTestArrayList does not exist in
the class or namespace. Thank you again!

DH

*** Sent via Developersdex http://www.developersdex.com ***
Mar 23 '06 #5
Hi,

see myu other post, the same issues apply

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dogmar Hoffman" <it******@itbranch.com> wrote in message
news:uq**************@TK2MSFTNGP14.phx.gbl...
Actually, a better representation is:

public int one(string conn,DateTime start,DateTime end)
{
try
{
ArrayList arrTestArrayList =
TestArrayList.LoadTestRecords(ConnectionString,Sta rtDate,EndDate);

foreach(thing something in anything)
{
something.Load(arrTestArrayList);
}
}
return 1;
}

public int GetStuff()
{
try
{
If (x = value in TestArrayList[6])
{
Do Something;
}
}
}

So in GetStuff, I would like to be able to get the values from
TestArrayList. Thank you very much and I hope that this is clearer.

DH

*** Sent via Developersdex http://www.developersdex.com ***

Mar 23 '06 #6

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

Similar topics

0
by: Brandon Potter | last post by:
Trying to find the best way to find common entries in an x number of ArrayLists or arrays of integers. Curious if there is a method already available in .NET to do just this very thing. ...
0
by: James | last post by:
I see that variations on this question have appeared before but I'm still completely stumped. I'm developing an application with a fairly robust graphics component for 3D rendering. I've written...
1
by: godsella | last post by:
First i have two stored procedures, i have passed the values of each one into two different arraylists of dates. how can i compare the two arraylists of dates? Thanks in advance
5
by: drdave | last post by:
I would like to have ten arraylists created within a loop.. is there a conversion or something I can do to acheive this.. pseudo: Dim counter As Integer = 0 Dim ArrName As ArrayList ...
0
by: steve | last post by:
I'm looking for a code example how to compare the values in a given record in different arraylists two arraylists, two fields in each record, both defined as string I'm thinking that it's...
3
by: steve | last post by:
I need to compare the value of a field in a row on an arraylist with the value of a field on a second arraylist I have this bit of code working for arrays but cant get it working for arraylists The...
4
by: Andy in S. Jersey | last post by:
I would like to create an unknown number of Arraylists, meaning, I don't know how many I should create until runtime. I will be reading a table, and 0,1,2, or more fields have to be put into...
2
by: Andy in S. Jersey | last post by:
I would like to create an unknown number of ArrayLists, that is I don't know that until runtime. Of course I can do this if I knew I needed two: ArrayList IntervalArray1 = new ArrayList();...
1
by: Newbie19 | last post by:
I'm just learning java arrays/arraylists and was wondering what are the best books for learning java arrays/arraylists? I know practice is the best way to learn, but I have a hard time...
3
by: =?Utf-8?B?Sm9zaFA=?= | last post by:
Hi All, I am attempting to compare values in two arraylists to make sure all the values are the same. I am running into trouble with my code if both arraylists compare okay up until a point and I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.