Visual Studio debugger - Displaying integer values in Binary

Type 'var, b' in the watch, for example, enter image description here


According to the Visual Studio debugger documentation:

You can change the format in which a value is displayed in the Watch, Autos, and Locals windows by using format specifiers.

This note on debugging engine updates and compatibility is also worth noting:

When the Visual Studio native debugger changed to a new debugging engine, some new format specifiers were added and some old ones were removed. The older debugger is still used when you do interop (mixed native and managed) debugging with C++/CLI.

Although it mentions it can be applied to Autos and Locals windows, it is unclear how it is done as the variable names cannot be edited in those windows.

A <variable>, <format> syntax may be used in Watch and Immediate windows, like so:

enter image description here

Here is a direct link to the complete list of format specifiers.


Right-click the value it’ll show a menu list, but it only give us the option of Hexadecimal Display. To display the variable with binary value in watch window, I suggest you write function to covert it :

enter image description here

The function that in my code is:

public static string ToBinaryString(uint num)
    {
        return Convert.ToString(num, 2).PadLeft(32, '0');
    }