D
Dave
Hi everyone,
Is it possible, using an Attribute or by some other means, to notify the C#
Compiler to serialize all static field's that have initializers before code
in an explicit static constructor?
Example:
public class MyClass
{
public static readonly int MyStaticField = 1;
static MyClass()
{
// Compiler emits the code to initialize MyStaticField as 1 here
Console.WriteLine();
// I need the compiler to emit the code here
}
}
-- I know it might not be clear as to why I need this functionality by
looking at the example above, but it would be helpful in my real-world
situation.
If you need details as to why I need this functionality from the compiler,
just let me know and I'll post it.
Thanks in advance,
~ Dave
Is it possible, using an Attribute or by some other means, to notify the C#
Compiler to serialize all static field's that have initializers before code
in an explicit static constructor?
Example:
public class MyClass
{
public static readonly int MyStaticField = 1;
static MyClass()
{
// Compiler emits the code to initialize MyStaticField as 1 here
Console.WriteLine();
// I need the compiler to emit the code here
}
}
-- I know it might not be clear as to why I need this functionality by
looking at the example above, but it would be helpful in my real-world
situation.
If you need details as to why I need this functionality from the compiler,
just let me know and I'll post it.
Thanks in advance,
~ Dave