Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this dictionary display differently in debug between VB.NET and C#?

I've been working in C# and VB.NET a lot lately, and the other night I noticed this strange behavior when running some through a debugger and trying to look at the contents of a Dictionary object. I'm fairly certain I've looked through a Dictionary in C# before and saw its contents, but now what I'm seeing is:

C# Dictionary in the debugger

Poking around in those sub parts, like the keys and values, doesn't show what's in the dictionary, just take me around in a loop to this same debugger window. I can't look at my values anywhere here.

Where as VB.NET looks fine:

VB.NET Dictionary in the debugger

Any idea why C# is different? Is there a setting or something I have off?

like image 965
cost Avatar asked Feb 18 '13 17:02

cost


People also ask

How can I see value while debugging in Visual Studio?

Run and Debug view# To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D.

How do you check if a key exists in a dictionary vb net?

To see if a key exists in a Dictionary, we should use ContainsKey or TryGetValue. If we just access the key directly, we might get a KeyNotFoundException. Note We can use exception handling to detect the KeyNotFoundException, but this will be slower than not causing an exception. Unhandled Exception: System.

Is it possible to change the value of a variable while debugging a VB NET application?

Yes, Visual Studio allows the developer to modify the value of a variable during debugging in a c# application. Set a breakpoint, hover the mouse above the variable so that a tooltip appears with the name of the variable and the variable's current value.

Is it possible to change the value of a variable while debugging?

Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.


1 Answers

Somehow you're being shown the "Raw View -> Non-Public members" window. However, the list of numerically-indexed values should be accessible if you scroll down in this window to the next-to-last row, "values". Can you post a screenshot showing the expanded "keys" window?

Uncheck Tools -> Options -> Debugging -> General, 4th option from last: "Show raw structure of objects in variable windows". (Thanks should also go to https://stackoverflow.com/a/13422426/2236012 for sharing this settings path.)

like image 100
C.B. Avatar answered Sep 27 '22 18:09

C.B.