Solved

Which of the Following Statements Is False

Question 14

Multiple Choice

Which of the following statements is false


A) Prior to C# 6, you could use a fully braced collection initializer to initialize a Dictionary’s key–value pairs. For example, if you had a Dictionary named toolInventory, you could create and initialize it as follows:

var toolInventory = new Dictionary{
{"Hammer", 13},
{"Saw", 17},
{"Screwdriver", 7}
};

B) The code in a) is shorthand for creating the Dictionary then using its Add method to add each key–value pair.
C) C# 6’s index initializers enable you to clearly indicate the key and the value in each key–value pair as follows:

var toolInventory = new Dictionary{
["Hammer"] = 13,
["Saw"] = 17,
["Screwdriver"] = 7
};

D) Prior to C# 6, any collection that defined an Add extension method could be initialized with a collection initializer. As of C# 6, the compiler also supports collection initializers for any collection that has an Add instance method.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents