#258 – Initializing a Static Variable as Part of Its Declaration

You can initialize a static variable at the time that it is declared.

        private static string LastDogToBark = "NOBODY";

The initialization of the field happens at runtime and is guaranteed to happen prior to the first time that the field is referenced or used.

Advertisements