Help...parameter passing confusion

  • Thread starter Thread starter Mat Andrews
  • Start date Start date
M

Mat Andrews

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
 
Mat Andrews said:
[...]
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.
 
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 said:
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 said:
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
 
Back
Top