I am designing some immutable classes but I have to have some variables like say .Count to have the total count of the instances. But would having a static variable affect multi-threading?
Because methods like Add, Remove, etc have to update the .Count value. Maybe I should make it lazy property?
If you’re just doing a counter, interlocked operations may be an option as well instead of a lock. MSDN has a nice example of this in the context of a reference count.