I need some advice, please!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working with .net framework 1.1 in C# for a windows application

I have 2 classes - A and B.
I have a function in B that is called by many functions in A.
I want to be able to detect in class B the parameters(data type and value)
of the calling function in class A.

Is this possible? If so, can anyone point me in the right direction?

Thanks in advance!
Paula
 
Hmmz.. if I read this, you have something like

classA
functionA(string name, int age)
classB.functionB()

functionA2(real amount, string city)
classB.functionB()

classB
functionB()

and you want code in B to access the parameters name and age you got in the
calling function A? (amount and city from calling A2...)

Do not know about accessing the callingstack @ runtime, but that seems to be
a hack and not really object oriënted. What you could do is create a
intermediate class like 'customParameter', which contains a few internal
variables (collections) that are set by functionA and functionA2.

Other approach is create overloaded functions of functionB that (offcourse)
have different signatures. Call a different functionB from all calling
functions. Create a base (generic) functionBBase that is called from the
overloaded functionB's for generic data processing.

Not knowing the exact situation this is all I solutions I can think off just
now. Is it possible to re-design this part aplication? Any more information?
 
Gerrit,

Thanks for the response - the situation you described is exactly what I need
to do. I had thought about the container idea and the overloaded functions
and either solution will work. I was wondering if there was a better way!

And the good news is I haven't written anything for the application yet so
redesign isn't an issue.

Thanks again!
 
I would say it's a bad idea as it only work with A & B.
what if a class C about which B knows nothing call B?

otherwise look at System.Diagnostic.StackTrace
 
Back
Top