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

Help...parameter passing confusion

Hi,

I'm comfused with this peice of code which I'm looking at. I can't figure
out how it works (and it does appear too);

ApplicationData appData = new ApplicationData();

ProductInfo.GetListOfCurrentLoanProducts("5" , "200",
ProductFactory);
ApplicationDataInfo.GetListOfCurrentItems(DateTime .Now , itemType,
appData );
int val = appData.ItemHeaders[0].itemId ;

My question is how can appData be populated by the call to
GetListOfCurrentItems (which is appears to be upon return)? Surely, as it
is not passed by reference how can the values be used upon returning from
the call?

The call ApplicationDataInfo.GetListOfCurrentItems is a void function of a
sealed class referenced by the calling assembly. Within this function the
parameter appData is populated.

Can anyone shed any light as this is annoying me!

Cheers,

Mat


Nov 16 '05 #1
2 1382
"Mat Andrews" <_r***************@ntlworld.com> wrote:
[...]
My question is how can appData be populated by the
call to GetListOfCurrentItems (which is appears to be
upon return)? Surely, as it is not passed by reference
how can the values be used upon returning from
the call?


It's an object of a reference type, so its properties can be changed
in the function even when it has not been passed by reference. The
difference with passing by reference is that you can then change the
actual object that the variable refers to, not just its properties.

P.
Nov 16 '05 #2
Sorry, my editing mistake;

ApplicationData appData = new ApplicationData();

//Line should read (i.e. passing appData)
ProductInfo.GetListOfCurrentLoanProducts("5" , "200", appData );

ApplicationDataInfo.GetListOfCurrentItems(DateTime .Now , itemType,
appData );
int val = appData.ItemHeaders[0].itemId ;

"RAyRAy" <RA****@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
Are you sure? Cause GetListOfCurrentItems is a static method and has no refrence to the instance called appData. It looks to me that the only time
there is any refrence to appData is during the constructor time. So check
this and see if it works:
ApplicationData appData = new ApplicatioinData();
int val = appData.ItemHeaders[0].itemID;

it should still work cause the 2nd line has nothing to do with appData and the third line is a static method without any refrence to appData. Try it,
let me know.
RAyRAy
HuhOiC
"Mat Andrews" wrote:
Hi,

I'm comfused with this peice of code which I'm looking at. I can't figure out how it works (and it does appear too);

ApplicationData appData = new ApplicationData();

ProductInfo.GetListOfCurrentLoanProducts("5" , "200",
ProductFactory);
ApplicationDataInfo.GetListOfCurrentItems(DateTime .Now , itemType, appData );
int val = appData.ItemHeaders[0].itemId ;

My question is how can appData be populated by the call to
GetListOfCurrentItems (which is appears to be upon return)? Surely, as it is not passed by reference how can the values be used upon returning from the call?

The call ApplicationDataInfo.GetListOfCurrentItems is a void function of a sealed class referenced by the calling assembly. Within this function the parameter appData is populated.

Can anyone shed any light as this is annoying me!

Cheers,

Mat


Nov 16 '05 #3

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

Similar topics

19
by: Mark Richards | last post by:
I've been programming for many years, but have only recently taken a deep "C" dive (bad pun, i know) and need a lot of explanation from an expert. My questions center around those mysterious...
4
by: sam1967 | last post by:
How do I get a function to return a GMP integer type mpz_t when i try it i get an error message. i am trying mpz_t hooch (int x) { mpz_t y; ........
16
by: Simon | last post by:
Hi all, I think I've seen someone passing an emumeration in code before. Can anyone tell me if thats possible and why i would want to. Many thanks Kindest Regards
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
4
by: Warren Sirota | last post by:
Hi, Please let me know if I am interpreting this correctly. I've done a little testing of the difference between passing parameters byVal and byRef, and the results were slightly non-intuitive,...
20
by: Brien King | last post by:
If I have a parameter that has an Object type (as opposed to something like a string), can I make that parameter a CONST? Right now, if you pass an object into a sub/function, that sub/function...
12
by: manochavishal | last post by:
Hi, I am having strange problem in my Program. I cannot paste the whole program as it is huge so just pasting the lines i think are necessary. I am passing a integer array pointer to a...
9
by: =?Utf-8?B?bGlhbnF0bGl0?= | last post by:
best way to use: an out method parameter or a method with return ?
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.