Calling Class and Static

  • Thread starter Thread starter msnews.microsoft.com
  • Start date Start date
M

msnews.microsoft.com

In the following classes ... it is possible when calling

MyDerived.Test()

to know that I am calling Test from MyDerived and NOT from MyClass?!

I have tried MethodInfo.GetCurrentMethod().ReflectedType ... but that
returns back MyClass.


public class MyClass
{


public static string Test()
{

}

}

public class MyDerived : MyClass
{


}




MyDerived.Test();
 
msnews.microsoft.com said:
In the following classes ... it is possible when calling

MyDerived.Test()

to know that I am calling Test from MyDerived and NOT from MyClass?!

No. It actually gets compiled to a call to MyClass.Test anyway.
 
Ahh ... good point. i hadn't thought of checking out the generated code ...

Thanks!

Brett
 
Yea ... I had thought of that, but here are the results

at MyClass.Test()
at MyClass.Main()

Brett
 
Back
Top