Exam4Training

When adding a new filename to the collection, which collection variable type will cause an error?

A developer examines a workflow in which filenames are stored within a collection. The collection is initialized with a single filename.

When adding a new filename to the collection, which collection variable type will cause an error?
A . System.Collections.Generic.Dictionary
B . System.Collections.Generic.List
C . System.Array
D . System.Data.DataTable

Answer: C

Explanation:

The collection variable type that will cause an error when adding a new filename to the collection is System.Array. This is because System.Array is a fixed-size collection that cannot be resized or modified once it is initialized. Therefore, if the collection is initialized with a single filename, it cannot accommodate any more filenames. To add a new filename to the collection, the developer should use a dynamic collection type, such as System.Collections.Generic.List or System.Data.DataTable, that can grow or shrink as needed. Alternatively, the developer can use System.Collections.Generic.Dictionary if the filenames need to be associated with some keys or values.

Reference: [Array Class], [Collection Classes]

Exit mobile version