Kimmo,
Generally speaking, you should be able to get up to "Foo" (namespace,
class, method). The Reflection APIs will give you this.
However, if you want to get "i", that's a little harder. You can
probably read the IL and determine that there is a variable of type int
initialized to 0, but it being named "i", that's only possible if you have
debug information in the assembly. If that is the case, then you can read
the source (however, you would have to do some parsing and matching), and
then get the variable name. As far as I know, there is nothing in the
framework that will aid you tremendously in this respect.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Kimmo Laine" <reply.to@newsgroup> wrote in message
news:Oa*************@TK2MSFTNGP09.phx.gbl...
Hi,
is there a way to get the declaration name/information of the type:
namespace MySpace {
internal class MyClass {
internal void Foo() {
int i = 0;
PrintInfo( i );
}
}
}
// . . .
static void PrintInfo( object o ) {
Type t = o.GetType();
// ? ? ?
}
I want that PrintInfo would print something like "Declaration:
MySpace.MyClass.Foo int i"!
I can get the int-part (hehe), but the rest...
thx
Kimmo Laine