How to find types referenced inside a method body dynamically in .Net.

I mean If I have a class "A" and it has a method "Method1". "Method1"
references object of class "B" (i.e there is an object created for Class "B"
in "Method1".). Hod do I find out the object of Class "B" in "Method1"
dynamically in .net

Re: Finding types inside a method body dynamically by Jon

Jon
Sat Apr 16 13:27:02 CDT 2005

Bidyadhar Patra <BidyadharPatra@discussions.microsoft.com> wrote:
> How to find types referenced inside a method body dynamically in .Net.
>
> I mean If I have a class "A" and it has a method "Method1". "Method1"
> references object of class "B" (i.e there is an object created for Class "B"
> in "Method1".). Hod do I find out the object of Class "B" in "Method1"
> dynamically in .net

I'm not entirely sure what you mean. Could you give an example, with an
appropriate "what do I do here" line at the bit you don't know?

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Re: Finding types inside a method body dynamically by Nick

Nick
Mon Apr 18 04:12:36 CDT 2005

Hi,

I think, if I understand correctly, you are looking for the keyword
TypeOf - but I may be mistaken - here is what I think you are asking and
how to solve it

Class A
Public Sub ClassASub1()
end sub
Public ClassAInteger1 as Integer
end class
Class b
Public Sub ClassBSub1(A as string)
end sub
Public ClassBBoolean1 as Boolean
End Class

Class Test
Public Sub TestIt()
dim Obj as Object
'First set it to be an instance of class A;
Obj = new A()

if TypeOf Obj is A then
CType(Obj, A).ClassASub1()
end if
'now set it to an instance of B
Obj = new B()
if typeOf(Obj) is B then
CType(Obj, B).ClassBSub1()
end if
end sub
end class

Is that what you wanted to know - does this explain / answer the question or
have I got the wrong end of the stick?

Nick

"Bidyadhar Patra" <BidyadharPatra@discussions.microsoft.com> wrote in
message news:A288DC07-2ED6-4C92-BF07-206A0DDDEA4E@microsoft.com...
> How to find types referenced inside a method body dynamically in .Net.
>
> I mean If I have a class "A" and it has a method "Method1". "Method1"
> references object of class "B" (i.e there is an object created for Class
"B"
> in "Method1".). Hod do I find out the object of Class "B" in "Method1"
> dynamically in .net