BlankHi,
How do I create a tightly coupled Object 1 such that when I update it in one collection, it is simultaneously and automatically updated in other collections? The collections are defined at the module level for the entire project to access as well as collections defined within different objects. Currently, I'm updating Object 1 manually in all the different collections but there surely must be a better way.
Thanks!
NJ 2 2022
BlankIf you add the same object reference to all the collections, then making a change to a property of the object, through any of the references to it, causes those changes to appear when the object is referenced through any of the collections. You create a single object, on the heap, and the variable that gets a reference to is just that: a reference to the single instance of the object, residing on the heap.
This is true for classes, at any rate. Structs (Types in VB.Net) might not work the same way, since when you add a struct to a collection it's boxed, and consequently I believe that there will be separate copies of the struct on each of the separate collections. However, if you stick with classes it'll work the way you want.
Tom Dacon
Dacon Software Consulting
"njp" <np***@systek.com> wrote in message news:eM**************@tk2msftngp13.phx.gbl...
Hi,
How do I create a tightly coupled Object 1 such that when I update it in one collection, it is simultaneously and automatically updated in other collections? The collections are defined at the module level for the entire project to access as well as collections defined within different objects. Currently, I'm updating Object 1 manually in all the different collections but there surely must be a better way.
Thanks!
NJ
BlankThanks Tom, this helps!
"Tom Dacon" <td****@community.nospam> wrote in message news:ui*************@TK2MSFTNGP11.phx.gbl...
If you add the same object reference to all the collections, then making a change to a property of the object, through any of the references to it, causes those changes to appear when the object is referenced through any of the collections. You create a single object, on the heap, and the variable that gets a reference to is just that: a reference to the single instance of the object, residing on the heap.
This is true for classes, at any rate. Structs (Types in VB.Net) might not work the same way, since when you add a struct to a collection it's boxed, and consequently I believe that there will be separate copies of the struct on each of the separate collections. However, if you stick with classes it'll work the way you want.
Tom Dacon
Dacon Software Consulting
"njp" <np***@systek.com> wrote in message news:eM**************@tk2msftngp13.phx.gbl...
Hi,
How do I create a tightly coupled Object 1 such that when I update it in one collection, it is simultaneously and automatically updated in other collections? The collections are defined at the module level for the entire project to access as well as collections defined within different objects. Currently, I'm updating Object 1 manually in all the different collections but there surely must be a better way.
Thanks!
NJ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Roger Bonine |
last post by:
I'm working on a rewrite of our employee database. I plan to implement a
fairly heavyweight base class, which includes 20 or 30 fields, including
address and phone number collections and the like....
|
by: Wing |
last post by:
Hi all,
I have created 2 tables in sql database and join these 2 tables before
assign the result to the dataset, and display the result in datagrid.
Everything is fine up to this point. The...
|
by: Jason Huang |
last post by:
Hi,
The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is
working for update,
but SqlParameter myPM =new SqlParameter
("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is...
|
by: Stephen Travis |
last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine
if I directly reference the array but if I pass the array as an...
|
by: njp |
last post by:
BlankHi,
How do I create a tightly coupled Object 1 such that when I update it in one collection, it is simultaneously and automatically updated in other collections? The collections are defined...
|
by: Marc Gravell |
last post by:
In the following example, the Bindings don't update the UI if the property
change is triggered from the non-UI thread - see the async button - from the
listbox contents (and observation) the change...
|
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= |
last post by:
I'm trying to figure out how to modify a panel (panel1) from a
backgroundworker thread. But can't get the panel to show the new controls
added by the backgroundwork task. Here is my code. In...
|
by: Bugs |
last post by:
Does anyone have any recommendations on the best way to create multiple
instances of the same class when the final number of instances is unknown?
For example, I have a class and based on some...
|
by: P.J.M. Beker |
last post by:
Hi there,
I'm currently writing a program in which I use the FileMonitor to monitor a
folder in which I store downloaded images. I know that I can't add much
coding in the filemonitor's event in...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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: 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...
|
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...
| |