C#のDictionaryでキーが重複した時のエラー
// Addメソッドで値を追加します。 | |
itemDict.Add(1, "ポーション"); | |
itemDict.Add(2, "ハイポーション"); | |
itemDict.Add(3, "エーテル"); | |
itemDict.Add(3, "エクスポーション"); | |
// キー 3 は既に辞書に追加されているのでエラーになります。 | |
// コンソールでは以下のように表示されます。 | |
// ArgumentException: An item with the same key has already been added. Key: 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment