Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
カスタム HResult または errorCode で例外をスローしたかったので、ExternalException を試しました
throw new ExternalException("Login required", 0x6acfc5);
ただし、例外をキャッチしてそれを見ると、それは別の奇妙な負の数HResultではないことがわかります。0x6acfc5
HResult
0x6acfc5
ExternalException("Login required", 0x6acfc5)
このコンストラクターは、errorCode を 2 番目のパラメーターとして受け入れます。 System.Int32
System.Int32
value0x6acfc5を int value に変換すると7000005、それが次のように表示されますHResult
7000005
あなたが電話すればex.HResult.ToString("X")あなたは得るでしょう6ACFC5
ex.HResult.ToString("X")
6ACFC5
注: ToString("X") int 値を 16 進文字列に変換します。
ToString("X")