Multiple choice technology programming languages

Which of the following is the correct syntax for using Dictionary object in your code:

  1. using System.Collections.Generic; Dictionary < string , StringBuilder >() dctobj = new Dictionary < string , StringBuilder >;

  2. using System.Collections.Generic; Dictionary < string , StringBuilder > dctobj = new Dictionary < string , StringBuilder >();

  3. using System.Collections.Generic; Dictionary < string , StringBuilder > dctobj = new Dictionary < string , StringBuilder >;

  4. using System.Text; Dictionary < string , StringBuilder > dctobj = new Dictionary < string , StringBuilder >();

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Option B shows correct Dictionary initialization syntax with proper type parameters and parentheses for instantiation. Option A is missing instantiation parentheses. Option C is missing parentheses. Option D uses wrong namespace (System.Text for StringBuilder is fine, but Dictionary needs Collections.Generic).