VB.NET: Get class name of a instance

Viewed 38172

Is there a way to get the instance's class name with VB.NET?

4 Answers

Using Reflection, you could do the following...

System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()

I use the following when logging trace info. This gives you the Class name, with all Namespaces and current Method name.

$"{System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()}.{MethodBase.GetCurrentMethod().Name}"
Related