Format Specifiers in C#

When you debug C# code in the Watch window or QuickWatch dialog box, you change the format in which a value is displayed using format specifiers.

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

Example

Suppose nVar is a character variable, and the Watch window shows the value as 0x0000F065. You want to see this value as decimal, but you do not want to reset the display of all variables to decimal. You can use the format specifier d to show the variable contents in decimal:

nVar,d

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

Specifier

Format

Value

Displays

ac

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.

d

Decimal integer

0x0065

101

dynamic

Displays the specified object using a Dynamic View

h

Hexadecimal integer

61541

0x0000F065

nq

String with No Quotes

"My String"

My String

hidden

Displays all public and non-public members

raw

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

results

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.

See Also

Tasks

How to: Watch an Expression in the Debugger

Other Resources

Variable Windows