1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C# 構造体・クラスのデバッグ表示をDebuggerDisplay属性で制御する

Last updated at Posted at 2020-06-27

構造体・クラスは変数ウィンドウで{ConsoleApp1.TestClass}のように表示されますが、DebuggerDisplay属性やDebuggerTypeProxy属性により表示を変更できます。

ここではDebuggerDisplay属性のよく使うパターンを紹介します。以下、iint型、ffloatまたはdouble型の変数またはプロパティです。

表記 概要
[DebuggerDisplay("{X}")] Xの値を二重引用符ありで表示する。
[DebuggerDisplay("{X,nq}")] Xの値を二重引用符なしで表示する。
[DebuggerDisplay("X:{X}")] 「X:」に続けてXの値を二重引用符ありで表示する。
[DebuggerDisplay("X:{X,nq}")] 「X:」に続けてXの値を二重引用符なしで表示する。
[DebuggerDisplay("{i.ToString(\"D10\")}")] iの値を10桁以上になるまで0で埋めて二重引用符ありで表示する。
[DebuggerDisplay("{X.ToString(\"D10\"),nq}")] iの値を10桁以上になるまで0で埋めて二重引用符なしで表示する。
[DebuggerDisplay("{X.ToString(\"X10\",nq)}]") iの大文字16進数表現を10桁以上になるまで0で埋めて二重引用符なしで表示する。
[DebuggerDisplay("{f.ToString(\"F2\")}")] fの値を小数点以下2桁まで二重引用符ありで表示する。
[DebuggerDisplay("{f.ToString(\"F2\"),nq}]") fの値を小数点以下2桁まで二重引用符なしで表示する。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?