c# - How to fix "CA1810: Initialize reference type static fields inline" with an abstract base...? -
here's simplified parts of code have: abstract class datamanager<tvalue> { protected static dictionary<string, tvalue> values; } and have: class textmanager : datamanager<string> { static textmanager() { values = ... // fill data } } and, i'm getting ca1810. see few solutions, making values public , setting them elsewhere, don't that, or making static method in textmanager same thing, invoked when program starts, don't either. i think it's obvious example, values should filled once per tvalue . so, think best solution here? i turn off rule. thing is, have rule (afaik) designed warn potential performance hit of using static constructor. initialization of static property can done either via static constructor or inline (as suggested msdn ). in case can't inline because: you have actual values in subclass there's no such thing abstract static method, can't delegate actual inline initia...