C Sharp (C#) - CollectionsWhy does collection initialization syntax require the collection to have an Add method?ABecause Add sorts the collection automaticallyBBecause Add is used to remove elements after initializationCBecause Add converts the collection to an arrayDBecause the compiler calls Add to insert each element during initializationCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand how collection initialization worksThe compiler translates collection initialization into calls to the Add method for each element.Step 2: Evaluate optionsBecause the compiler calls Add to insert each element during initialization correctly explains the role of Add; others describe unrelated behaviors.Final Answer:Because the compiler calls Add to insert each element during initialization -> Option DQuick Check:Collection initialization uses Add method internally [OK]Quick Trick: Add method is called for each item during collection initialization [OK]Common Mistakes:MISTAKESThinking Add removes or sorts elementsAssuming Add converts collections to arrays
Master "Collections" in C Sharp (C#)9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More C Sharp (C#) Quizzes Classes and Objects - Constructors and initialization - Quiz 10hard Classes and Objects - Instance fields and state - Quiz 2easy Collections - HashSet for unique elements - Quiz 14medium Exception Handling - Try-catch execution flow - Quiz 2easy Exception Handling - Try-catch execution flow - Quiz 11easy File IO - Why file operations matter - Quiz 11easy File IO - Working with JSON files - Quiz 3easy Inheritance - Sealed classes and methods - Quiz 13medium LINQ Fundamentals - Why LINQ is needed - Quiz 1easy Strings and StringBuilder - StringBuilder methods and performance - Quiz 10hard