[C#] . [Diagnostic] 常见的Diagnostic标记

1. [DebuggerStepThrough]

the Visual Studio debugger does not stop in a method that is marked with this attribute even if a breakpoint is set in the method.

VS将不会进入被该属性标记的代码块


2.[DebuggerDisplay("{Caption}")]

The DebuggerDisplay attribute has a single argument, which is a string to be displayed in the value column for instances of the type. This string can contain braces ({ and }). Text within a pair of braces is evaluated as a field, property or method.

The following table shows some possible uses of the DebuggerDisplay attribute and example outputs.

Attribute Output appearing in the Valuecolumn)
[DebuggerDisplay("x = {x} y = {y}")]

Used on a type with fields x and y.
x = 5 y = 18
[DebuggerDisplay("String value is {getString()}")]Parameter syntax can vary between languages. Therefore, use it with care. String value is [5, 6, 6]

DebuggerDisplay  有一个参数,参数包含("{}"), 内部的string(例如("{Caption}")) 会被评估为一个字段、属性、或者方法。




猜你喜欢

转载自blog.csdn.net/u011144776/article/details/80911437
今日推荐