locked
break when variable gets a specific value? RRS feed

  • Question

  • Hi,

      I was wondering how do I set the Visual Studio 2012 debugger to break at a certain line when a variable gets assigned a specific value?  And I know that in C# "everything" (or almost everything) is an object, but what about non-value type objects, where you determine their "value" by more than one variable/field/object (I don't know what the correct terminology is here, please bare with me)

      So I'm wondering how to do this, for example, for variables where their value is determined by one "value" (which are objects I know, what is the correct terminology for the type?) like string, String, Int32, int, bool, etc.. and also for multi-value objects (what's the term for these?), where the uniqueness of the object aside from the reference is determined by more than one value.  If someone could let me know how to do this, that would be great, and I'll mark as answer if you're the first one to answer correctly and I can verify that it is correct, and possibly (but not guaranteed) if you provide useful elaboration that the first person to answer didn't provide information on.


    • Edited by jamesiw Wednesday, May 15, 2013 3:55 PM
    Wednesday, May 15, 2013 3:55 PM

Answers

  • Right click on the breakpoint, and set a Condition at which the breakpoint will break.  This allows you to say things like, break when:

    obj.x == 24


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by jamesiw Wednesday, May 15, 2013 5:09 PM
    Wednesday, May 15, 2013 4:03 PM