Format Specifiers in C#
Collapse the table of content
Expand the table of content

Format Specifiers in C#


You can change the format in which a value is displayed in the Watch window using format specifiers. You can also use format specifiers in the Immediate window, the Command window, and even in source windows. If you pause on an expression in those windows, the result will appear in a DataTip. DataTips will reflect the format specifier in the DataTip display.

To use a format specifier, type the expression followed by a comma. After the comma, add the appropriate specifier.

If you have the following code:

	    int my_var1 = 0x0065;
	    int my_var2 = 0x0066;
    	int my_var3 = 0x0067;

Add the my_var1 variable to the Watch window (while debugging, Debug / Windows / Watch / Watch 1) and set the display to hexadecimal (in the Watch window, right-click the variable and select Hexadecimal Display). Now the Watch window shows that it contains the value 0x0065. To see this value expressed as a decimal integer instead of a hexadecimal integer, in the Name column, after the variable name, add the decimal format specifier: , d. The Value column now displays the decimal value 101


The following table shows the C# format specifiers recognized by the debugger.



Original Watch Value



Force evaluation of an expression. This can be useful when implicit evaluation of properties and implicit function calls is turned off. See Side Effects and Expressions.

Message “Implicit function evaluation is turned off by the user”



decimal integer




Displays the specified object using a Dynamic View

Displays all the members of the object, including the Dynamic View

Displays only the Dynamic View


hexadecimal integer




string with no quotes

"My String"

My String


Displays all public and non-public members

Displays public members

Displays all members


Displays item as it appears in the raw item node. Valid on proxy objects only.


Raw View of Dictionary<T>


Used with a variable of a type that implements IEnumerable or IEnumerable<T>, usually the result of a query expression. Displays only the members that contain the query result.

Displays all the members.

Displays the members the meet the conditions of the query.

© 2015 Microsoft