In .NET (originally .NET CF), how to get full address and name of an object?
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Button myButton = new Button();
MessageBox.Show(GetFullName(myButton));
}
string GetFullName(object obj)
{
string path = null;
// should retrieve the 'WindowsFormsApplication1.Form2.myButton' , but how?
return path;
}
}
}
myButton
isn't really accurate under the usual interpretation ofnamespace.type.member
.myButton
is just a local variable, not a member ofForm2
. Can you tell us why you want this information?public static
field, but that's quite different from a local variable. Fields of a type do have names at run-time, and can be retrieved using reflection.