PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 23?

You develop an application by using C#. The application counts the number of times a specific word
appears within a set of text files. The application includes the following code. (Line numbers are
included for reference only.)

You have the following requirements:
Populate the _wordCounts object with a list of words and the number of occurrences of each word.
Ensure that updates to the ConcurrentDictionary object can happen in parallel.
You need to complete the relevant code.
Which code segment should you insert at line 23?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

4 Comments on “Which code segment should you insert at line 23?

  1. Lord Vader says:

    A
    AddOrUpdate(TKey, TValue, Func)
    Adds a key/value pair to the ConcurrentDictionary if the key does not already exist, or updates a key/value pair in the ConcurrentDictionary by using the specified function if the key already exists.

    GetOrAdd(TKey, TValue)
    GetOrAdd Adds a key/value pair to the ConcurrentDictionary if the key does not already exist.

    there is another getorAdd overload but it isnt used here that wuold have worked:
    GetOrAdd(TKey, Func)
    Adds a key/value pair to the ConcurrentDictionary by using the specified function, if the key does not already exist.




    2



    0

Leave a Reply