If I understood correctly, you have an object with a lot of properties, then you can make a method in that class that would 'scan' all the properties using C# reflection.
Create a method like this in the class of the object you want to analyze:
string PropertyThatHasCertainValue(object Value)
{
Type myType = this.GetType();
while(myType != typeof(object))
{
foreach (PropertyInfo property_info in myType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
if (object.Equals(property_info.GetValue(this, null), Value))
{
return property_info.Name;
}
}
myType = myType.BaseType;
}
return "No property has this value";
}
Then in the watch, add a following watch:
MyObjectInstance.PropertyThatHasCertainValue(ValueYouAreLookingFor)
Note that you might want to use something else but object
as a parameter, to make it easier to type in the watch, but VS watch Window you can easily type not only numbers and strings but also enums. Visual Studio watches are extremely powerful, they will almost always evaluate the expression correctly.
I have added the while loop to go recursively through all the parents. BindingFlags.NonPublic
will return all private and protected methods of the class, but not the private methods of base classes. Navigating through all the base classes, until hitting Object will solve this.