In one of our old services I found such piece of code (comments are original):
long[] tasksCounter = {0}; //boxing for long counters
long[] errorsCounter = {0}; //boxing for long counters
Further in the code these "arrays" are used with Interlocked class: Interlocked.Increment(ref errorsCounter[0]), Interlocked.Read(ref errorsCounter[0]) etc).
I wonder why did not the author use basicaly long tasksCounter, errorsCounter?
Probably this approach has benefits I don't know about?
It's probably worth mentioning that the variables are used in async lambda. When I change it to basic long Resharper plugin warns me with "Access to modified closure" and suggests to wrap it in array. I found couple of questions about it: