How do I get parameter values?

  • Thread starter Thread starter Tiberiu Covaci
  • Start date Start date
T

Tiberiu Covaci

If I have the following code :

private void A (Type1 param1, Type2 param2 ....){

B();
}

private void B(){
....
}

How can I find out the values for the param1, param2 ... inside B method,
without sending them to B? Is there any posibility to achieve that?

Tahnks,
Tibi.
 
Tiberiu Covaci said:
If I have the following code :

private void A (Type1 param1, Type2 param2 ....){

B();
}

private void B(){
....
}

How can I find out the values for the param1, param2 ... inside B method,
without sending them to B? Is there any posibility to achieve that?
No, not really, it'd be best just to pass the parameters in as appropriate..
 
The problem I would like to solve is to call B from several methods, and
then generate something like:
MethodName?param1=param1Value&param2=param2Value....

Tibi.
 
The problem is that the parameters passed to A are not visible to B,
even when B is called from A. That's just scoping for you.

You will have to either (1) use global variables or something similar
[a VERY bad habit, and one which I don't recommend] or (b) pass the
arguments to B.
 
I have another solution which is simpler, I send all the parameters, along
with their values as prams string[] into B. What I wanted to achieve at
first was something like several methods calling B with different parameters
and values, as all the metdods do the same thing, they send a command name
and a list with parameters (name=value). If this would have worked, the only
thine I would then had to do was to declare the method, and use the right
parameter names, and the only thing the method would have to do would be to
call B which will solve the rest.

Best regads,
Tibi
MCT, MCSD.NET
 
You couldn't have achieved all that with function overloading?

And don't you sacrifice type-safety by passing in an array of strings?
Are you CERTAIN you'll always get valid data? I'd have to assert the
hell out of that.
 
Back
Top