C#のDictionaryでキーが重複した時のエラー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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