473,837 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating ArrayList

Hi.
I have ArrayList that contains structures...
I need to iterate through all structures in this array and update one of
members in this structures...
The first thing that comes to mind is just use foreach, store struct in
temp variable , update it , then write it back to array to the same
position.
Is there more efficient way?

Thanks..

Nov 15 '05 #1
2 3594
Hi Rustam

Why not cast the element inside your arraylist to the struct, modify the
member, and then put it back?

--
Cobus Lombard
Application Developer
Mint Net
South Africa

"Rustam Asgarov" <ru****@boun.ed u.tr> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi.
I have ArrayList that contains structures...
I need to iterate through all structures in this array and update one of
members in this structures...
The first thing that comes to mind is just use foreach, store struct in
temp variable , update it , then write it back to array to the same
position.
Is there more efficient way?

Thanks..

Nov 15 '05 #2
Hi,

I think you have select the wrong object to store your data..

Structures are value type and Collections (ArrayList) are more effecient
with reference type since reference type are created as objects mean you
avoid object boxing.

but if the arraylist consist of so many element by bet is to store them in a
static Array (at the initial stage if you can) or
use ToArray method to get a strucure type array from the array list and do
the operation using a for loop

else if the arraylist contain small amout of data, it is to your wish

Nirosh.

"Rustam Asgarov" <ru****@boun.ed u.tr> wrote in message
news:#8******** ******@TK2MSFTN GP12.phx.gbl...
Hi.
I have ArrayList that contains structures...
I need to iterate through all structures in this array and update one of
members in this structures...
The first thing that comes to mind is just use foreach, store struct in
temp variable , update it , then write it back to array to the same
position.
Is there more efficient way?

Thanks..

Nov 15 '05 #3

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

Similar topics

0
2355
by: willow1480 | last post by:
I am developing a small little Service Control Application. I am using a listview control with checkboxes and getting the list of services I want to control from a text file. When you check a checkbox, it should either stop the service or start the service depending on each respective service's status. I want the listView to update the status for each service as they are checked. instead all I can seem to do is clear the listView and I...
1
1244
by: Patrick Delifer | last post by:
HI, I am trying to update a DataGrid where I want to rebind just the row that was updated. Here's the situation: 1) Updating is not a problem, it works fine. 2) I am not using ItemCommand (edit, delete, etc) 3) the button that issues the update/rebind is outside the datagrid, on the web form. Till now I have been issuing a full DataBind for the entire DG, that I read
1
1445
by: hazz | last post by:
I have two arraylists that populate two Grid controls. I have two Calendar controls to select a 'From' and 'To' date to filter what is in the grid for subsequent filtered views of the what is contained in the lower grid. The rows of the grid are derived unbound through an arraylist of objects that contain the column values. I am using Session Variables to store the arraylist contents on the inital Page_Load after making initial database...
14
2137
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these grid and write to the database and I set the new Primary Keys and related Fields to the new asigned atuonumbers in the Access.
1
1417
by: Bob | last post by:
I have an arraylist (arlNAMES) that is bing used as a datasource for a combobox. When an item is selected in the combobox I want to remove it from both the combobox and the arraylist. This doesn't work. DOes anyone know why and how to fix it? Dim intPOS As Integer = cboAdvanceResponse.SelectedIndex cboAdvanceResponse.DataSource = Nothing arlNAMES.RemoveAt(intPOS) arlnames.TrimToSize arlREF.RemoveAt(intPOS)
0
958
by: Emily | last post by:
I am new to VB.NET and I need help finding and updating values in an arraylist. My arraylist is called arrVarInfo and holds data in this structure type: Public Structure VarInfo Dim Name As String Dim Format As String Dim Desc As String
8
2004
by: Jeffrey Spoon | last post by:
Hello, according to the docs you can update a DataGrid with an ArrayList. I have created an ArrayList and I add these objects: Dim patient1 As New Person patient1.Reading = 1 patient1.ReadingValue = 50 myArray.add(person1) Dim patient2 As New Person patient2.Reading = 2 patient1.ReadingValue = 60
3
1178
by: Terry Olsen | last post by:
I have a listbox that uses an ArrayList for a datasource. When I change the information in the ArrayList, is there no way to "Refresh" the listbox other than...? Listbox.DataSource=Nothing Listbox.DataSource=ArrayList *** Sent via Developersdex http://www.developersdex.com ***
4
10341
by: iKiLL | last post by:
Hi all, I am using C# on VS2005. I have a solution with 2 projects, a Webservice and a Client application. Both of these to projects can build compile and run.
0
9682
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10871
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...
1
10621
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
10268
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
9396
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...
1
7806
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5846
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3123
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.