473,472 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

passing objects in a collection as ref

I have a collection of objects, call them MyObject, that I
store in a Hashtable , myHashTable(with dates as keys for
instance). These are VERY large objects and I have
functions that take them as a 'ref' argument. Now I don't
need to change any of the data in them -- I simply pass
them by ref so that I don't have to make a copy. I have
just discovered that you can't pass properties as 'ref'
arguments because they are read only. So I can't pass
((MyObject) myHashTable[myDate]) as a ref argument to the
function.

How can I maintain a collection of parameterized objects
(by a date or string) that can be passed as a ref argument
to a function.

Thanks,

Jeff.
Nov 15 '05 #1
1 3666
Thanks Jon!

That was very clear. I have been coding in C# for about a
month now and the book I have been using never made that
clear. I thought that since you had to explicitly use
the 'ref' that by default objects (of classes) were
always copied otherwise -- and wasted a lot of time
trying to work around the problem. Now I don't need to
change anything, just delete all the 'ref's in my code!

Cheers,

Jeff.
-----Original Message-----
jeff <j.*******@comcase.net> wrote:
I have a collection of objects, call them MyObject, that I store in a Hashtable , myHashTable(with dates as keys for instance). These are VERY large objects and I have
functions that take them as a 'ref' argument.
Are you sure you actually need to? When you say they are

very largeobjects, are they value types? If so, do they really *need* to be?
If you're dealing with reference types, I don't think you've got theproblem you think you have - see
http://www.pobox.com/~skeet/csharp/parameters.html
for more information.

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

Nov 15 '05 #2

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

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
6
by: Mike Guerrieri | last post by:
I have a few objects that I've created, Contact, Address, AddressCollection (inherits from CollectionBase), dtaContact, and dtaAddress. One of the properties of the Contact object...
1
by: vbvjain | last post by:
I am developing an applocation which reads mails in outlook inbo alongwith attachments and all these informmation is stored in collection which i need to pass it to a web service, which will perfor...
1
by: PJS | last post by:
I am trying to use a COM object which has a parameter of type Collection in VB6. .Net recognizes this collection as a VBA.Collection object. When I try creating a VBA.Collection in .Net using: ...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
3
by: Malcolm | last post by:
Hi. I am attempting something new in my coding and need some direction. I have a web service that I am attempting to return a custom colleciton of custom objects of a single type. When I call...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
2
by: =?Utf-8?B?Y3Nz?= | last post by:
I am new to ASP.net webservice and have a quesiton. Is is possible to pass custom object to a web service (using VB 2005)? My custom object will look like this Public Class Myclass Public...
2
by: Torsten Z | last post by:
Hi, I have tried several things to passing an array of objects or a Object Collection from .NET to VB6 but I can't get it work. Passing one object works fine, but more than one not. Has anybody...
3
by: Subodh | last post by:
Hi All, In C++ we could pass a constant reference to a function so that the target function could not modify the objects passed eg. const classA & dummmyfunction(const classB) similar thing...
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
marktang
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,...
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
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.