Time for action – creating the blocks

Follow the given steps:

  1. Create a console application. Call it SurveyDonkeyTest.
  2. Make sure you add the following directives:
    using System.Collections.Concurrent;
    using System.IO;
    using System.Threading.Tasks;//Needed for TPL
  3. Add the following variables to the file Program.cs:
    static ConcurrentDictionary<string, int> votes = new ConcurrentDictionary<string, int>();
    
    static ConcurrentBag<string> options = new ConcurrentBag<string>();
    
    static List<string> fruits = new List<string>();
  4. Add the following code to read all fruit names:
    //You can create your own version of Fruits.txt to store names of //few fruits //or you can download it from the book website StreamReader optionReader = new StreamReader("Fruits.txt"); fruits.AddRange(optionReader.ReadToEnd().Split(new ...

Get .NET 4.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.