Is there a way to force the initialization order of a static field in partial classes? Let's say in HelloWorld1.cs I have:
partial class HelloWorld
{
static readonly string[] a = new[] { "Hello World" };
}
Elsewhere in HelloWorld2.cs I have:
partial class HelloWorld
{
static readonly string b = a[0];
}
If a is initialized to b, this is normal, but if b is initialized to a, then it returns a. A healthy way is probably to use a static constructor, but I'm curious if there is a way to force or predict the initialization order when the field classes are in different files of the same partial class.
source
share