What does this do exactly?
var counts = new Dictionary<string, int>();
for (int i = 0; i < 10; i++)
counts[string.Format("STA Thread Queue Worker Thread No. {0}", i + 1)] = 0;
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first line will create a new Dictionary with strings as keys and int as values for these keys,
it is like a Hash Table.
The second line will execute the third line 10 times, with i from 0 to 9.
In the third line, we will store the string in the Dictionary together with its value in a way that it can be quicly looked up, with strings containing i + 1 which is 1 to 10 and set their corresponding value to 0.
Tip: It would be better to use an array for this, there is no need for hashing strings as they are static except for the integer. The string can thus be concatenated later when needed.
Or even shorter, as the elements are 0 by default: