C Sharp (C#) - CollectionsWhat happens if you try to add duplicate keys using a Dictionary initializer in C#?AThe last value for the duplicate key overwrites previous onesBRuntime exception is thrownCDuplicate keys are ignored silentlyDCompile-time error occursCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand Dictionary initializer behaviorDuplicate keys in initializer cause runtime exceptions, not compile errors.Step 2: Exception typeArgumentException is thrown at runtime when duplicate keys are added.Final Answer:Runtime exception is thrown -> Option BQuick Check:Duplicate keys cause runtime exception = D [OK]Quick Trick: Duplicate keys cause runtime exception, not overwrite [OK]Common Mistakes:MISTAKESAssuming last value overwrites silentlyExpecting compile-time errorThinking duplicates are ignored
Master "Collections" in C Sharp (C#)9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More C Sharp (C#) Quizzes Collections - Why collections over arrays - Quiz 6medium Exception Handling - Finally block behavior - Quiz 14medium File IO - Why file operations matter - Quiz 8hard File IO - Why file operations matter - Quiz 2easy File IO - Writing text files - Quiz 10hard Inheritance - Protected access modifier - Quiz 2easy Interfaces - Interface vs abstract class decision - Quiz 11easy LINQ Fundamentals - LINQ query syntax - Quiz 4medium LINQ Fundamentals - Where clause filtering - Quiz 15hard Polymorphism and Abstract Classes - Abstract classes and methods - Quiz 4medium