static readonly field initializer vs static constructor initialization
Below are two different ways to initialize static readonly fields. Is there a difference between the two approaches? If yes, when should one be preferred over the other? class A { private static readonly string connectionString = WebConfigurationManager.ConnectionStrings["SomeConnection"].ConnectionString; } class B { private static readonly string connectionString; static B() { connectionString = WebConfigurationManager.ConnectionStrings["SomeConnection"].ConnectionString; } } Mark Byers There is one subtle difference between these two, which can be seen in the IL code - putting an explicit