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

Passing Data

Hi,

I have a hashtable that I need to pass around to different Business Objects.
My question is it better to pass it and make a locale hashtable variable and
set it equal to the passed hashtable or should I pass it and not worry about
it?

Thanks
Nov 15 '05 #1
4 2557
Jack,

It doesn't really matter which you do. The reason is that if you set
the variable equal to the hashtable, then it is a reference to the instance.
If the instance is passed to other objects, then changes that they make will
be reflected in the hashtable that your business object is holding a
reference to.

You might want to consider cloning the hashtable for passing around.
Also, you might want to consider a data table as well (although you don't
have to), it's just that there is a little more type safety involved
(columns are of a certain type).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jack" <j@mse.com> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a hashtable that I need to pass around to different Business Objects. My question is it better to pass it and make a locale hashtable variable and set it equal to the passed hashtable or should I pass it and not worry about it?

Thanks

Nov 15 '05 #2
Thanks for the post. Since the changes each BO will make on the hashtable
needs to be reflected I will continue to pass it by ref. The reason why I
am using a hashtable instead of a datatable because I do not know the
structure of data and just add data to it at runtime. I rather use a
datatable however it seems to me that it is harder (at runtime) to add
columns and data.

Thanks

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:u1**************@TK2MSFTNGP10.phx.gbl...
Jack,

It doesn't really matter which you do. The reason is that if you set
the variable equal to the hashtable, then it is a reference to the instance. If the instance is passed to other objects, then changes that they make will be reflected in the hashtable that your business object is holding a
reference to.

You might want to consider cloning the hashtable for passing around.
Also, you might want to consider a data table as well (although you don't
have to), it's just that there is a little more type safety involved
(columns are of a certain type).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jack" <j@mse.com> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a hashtable that I need to pass around to different Business

Objects.
My question is it better to pass it and make a locale hashtable variable

and
set it equal to the passed hashtable or should I pass it and not worry

about
it?

Thanks


Nov 15 '05 #3
Jack <j@mse.com> wrote:
Thanks for the post. Since the changes each BO will make on the hashtable
needs to be reflected I will continue to pass it by ref.


No, you don't *need* pass it by ref, because a reference is the value
which is being passed anyway.

See http://www.pobox.com/~skeet/csharp/parameters.html for a fuller
explanation.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4
Jack,

Because a Hashtable is a reference type, you are always passing the
reference around. When you pass it to a method, the reference is passed,
and that reference is passed by reference, or by value.

Creating the structure of a datatable is easy. You just have to add
DataColumn instances to the Columns on DataTable class (it might be a little
more complex, but that is the thrust of it).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jack" <j@mse.com> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
Thanks for the post. Since the changes each BO will make on the hashtable
needs to be reflected I will continue to pass it by ref. The reason why I
am using a hashtable instead of a datatable because I do not know the
structure of data and just add data to it at runtime. I rather use a
datatable however it seems to me that it is harder (at runtime) to add
columns and data.

Thanks

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:u1**************@TK2MSFTNGP10.phx.gbl...
Jack,

It doesn't really matter which you do. The reason is that if you set the variable equal to the hashtable, then it is a reference to the

instance.
If the instance is passed to other objects, then changes that they make

will
be reflected in the hashtable that your business object is holding a
reference to.

You might want to consider cloning the hashtable for passing around.
Also, you might want to consider a data table as well (although you don't have to), it's just that there is a little more type safety involved
(columns are of a certain type).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jack" <j@mse.com> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a hashtable that I need to pass around to different Business

Objects.
My question is it better to pass it and make a locale hashtable
variable and
set it equal to the passed hashtable or should I pass it and not worry

about
it?

Thanks



Nov 15 '05 #5

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

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
9
by: Just Me | last post by:
PARAFORMAT2 is a structure that SendMessage will return stuff in. Is the "ref" correct or since only a pointer is being passed should it be by value? Suppose I was passing data rather then...
3
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers:...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
3
by: DaTurk | last post by:
If I call this method, and pass it a byte by ref, and initialize another byte array, set the original equal to it, and then null the reference, why is the original byte array not null as well? I...
3
by: iu2 | last post by:
Hi all, I need your professional opinion about this. It is more a general programming dilemma rather then a C++ one, but since the project I write is in C++... We handle big structs of data....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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:
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...
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...
0
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...
0
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...

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.