By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 2,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

Help...parameter passing confusion

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.