| Jon Skeet: Coding Blog |
To some readers, the title of this post may induce nightmarish recollections of late-night debugging sessions. To others it may be simply the epitome of jargon. Just to break the jargon down a bit: Type initializer: the code executed to initialize the static variables of a class, and the static constructor Circular dependency: two bits of code which depend on each other - in this case, two classes whose type initializers each require that the other class is initialized A quick example of the kind of problem I'm talking
about would be helpful here. What would you expect this code to print?
using System;
class Test
{
static void Main()
{
Console.WriteLine(First.Beta);
}
}
class First
{
public static readonly int Alpha = 5;
public static readonly int...(Read whole news on source site)
class Test
{
static void Main()
{
Console.WriteLine(First.Beta);
}
}
class First
{
public static readonly int Alpha = 5;
public static readonly int...(Read whole news on source site)
Home : Blog List : Jon Skeet: Coding Blog : Type initializer circular dependencies




