Find the Calling CLASS name !!

asp.net , class , event , csharp , 2.0 Milan, Italy
  • 7 years ago

    Hi ! I need to retrieve the Calling-Class-name...

    For example.. if I Have a code like this

    MyTest MyCallingClass= new MyTest(); 
    Response.Write(MyCallingClass.test_A());
    

    and I also have a class "MyTest" like this

        public class MyTest
        {
           public string test_A()
           {
             return   ??????????.ToString()
            }
        }
    

    In my page I Want to see "MyCallingClass" So.. How can I retrieve the name "MyCallingClass" from MyTest

    Thanx and sorry for my bad english!!

  • 7 years ago

    Hi,

    with something like that?

    Imports System.Reflection

    public sub bla

    txtMain.Text = MethodBase.GetCurrentMethod.ToString
    

    end sub

    Look at MethodBase.GetCurrentMethod.

    Greets, dh

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Java is to JavaScript what Car is to Carpet.” - Chris Heilmann