In this case, the two classes are identical. In fact, for almost all purposes, the two styles of code that you used are the same. In general, you will find that most style guides recommend using field initializers (this is especially true for static field initializers).
There is one subtle difference, but it is very unlikely that it will ever affect you.
Whenever you initialize members of the inline class, C # generates code to perform this initialization immediately before running any code in the constructor. In particular, if your constructor calls the base class constructor. Field initializers are started before the base class constructor is called, and the code in your user-created constructor must be run later. That is, the following two classes are slightly different:
public class B : A {
Note that if you do not provide a default constructor, C # automatically provides the one that calls base() for you, which makes the class “look like” to class B , even if you do not explicitly provide B() .
In practice, the difference is hardly significant. In fact, you cannot refer to this in your field initializers, so you cannot rely on the base class that is created anyway.
source share