Is the “textual order” across partial classes formally defined?

后端 未结 2 933
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 06:34

Specifically, in relation to field initializers (in this case, static) - §17.11 in ECMA 334:

If a class contains any static fields with initializers,

2条回答
  •  醉酒成梦
    2020-12-03 07:18

    I know this question is very old, but here is the correct part of the specification:

    ECMA-334 (C# Language Specification), Variable initializers, section 17.4.5:

    When there are field declarations in multiple partial type declarations for the same type, the order of the parts is unspecified. However, within each part the field initializers are executed in order.

    So the "textual order" in partial types is not undefined, rather it's partially defined. ;-)

提交回复
热议问题