Consider the following code snippet from .NET 4.0 library:
private T[] array;
private static T[] emptyArray;
private int size;
private int version;
static Stack()
{
Stack<T>.emptyArray = new T[0];
}
public Stack()
{
array = Stack<T>.emptyArray;
size = 0;
version = 0;
}
Is there any reason behind initializing value type private fields to default values (size
and version
in the example above) explicitely other than coding standards of the company?