Passing an array of properties to a method.

  • Thread starter Thread starter craigkenisston
  • Start date Start date
C

craigkenisston

Hi,

I created an array of objects like this :

object[] Values = {myObject.myprop, otherobject.otherprop,
thirdobject.xprop};

Then I pass it to a method. and I get the values filled in that method.
I can debug the method and values are being assigned.
But when I am in the calling procedure I no longer see the values, I
mean, they don't keep in each object's property.
I tried passing the object array by "ref" and still no luck.

Please, let me know if this is possible or I am just smoking cheap <g>.
 
I created an array of objects like this :

object[] Values = {myObject.myprop, otherobject.otherprop,
thirdobject.xprop};

Then I pass it to a method. and I get the values filled in that method.
I can debug the method and values are being assigned.
But when I am in the calling procedure I no longer see the values, I
mean, they don't keep in each object's property.

No, they wouldn't. You're not actually passing the properties - you're
passing the values of the properties.
I tried passing the object array by "ref" and still no luck.

Please, let me know if this is possible or I am just smoking cheap <g>.

You either need to pass an array of PropertyInfos (and the objects on
which to call them), or change the array in the method call and then
afterwards do something like

myObject.myprop = values[0];
otherobject.otherprop = values[1];
thirdobject.xprop = values[2];
 
Back
Top