4

This is one of those weird ones that feels like I must be seeing things, but here is some code I am debugging:

    private byte[] myCode = null;

    ...

    public bool Tampered
    {
        get
        {
            return Bytes == null;
        }

        set
        {
            if (value)
            {
                if (Bytes != null)
                {
                    ProcessBytes();         /* BREAKPOINT HERE */
                    myCode = null;
                }
            }
        }
    }

I run my code, which executes someObject.Tampered = true; and breaks on the breakpoint. At this point, the debugger shows mycode == bytes[3]. All is well. I step over ProcessBytes. All is still well.

Then, I step over myCode = null; and the debugger shows myCode == bytes[0].

What's going on? Have I just somehow fundamentally broken something? myCode isn't a property, so it shouldn't be doing anything odd. Is there some quirk of arrays in C# that I've somehow previously not known about?

2
  • 2
    Oh, never mind. It was all my fault. Stating the problem out loud helped though. Turns out the debugger was calling 'get' which called the Bytes property, which re-created the array. Commented Nov 10, 2010 at 14:51
  • 2
    You take my time to test your fault. Commented Nov 10, 2010 at 14:59

1 Answer 1

1

I think the debugger might be showing you the type of myCode, which is in this case an (unassigned) byte array with zero length.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.