Meeting the needs of your business from a distance

Static Type Initialization in .NET 4.0

by mark shiffer 1. February 2010 07:56

Jon Skeet has a rather interesting article over on his blog called "Type initialization changes in .NET 4.0". In it he explains through example how static methods and variables affect the timing of when the type gets initialized. Essentially, in 3.5, as soon as you hit a reference to a type it is initialized. This is not the case with 4.0. The CLR is more intelligent now and only initializes the type once static member variables are referenced. So, if you have a static method on a type that is fully encapsulated, the method can be called without the type being initialized.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Programming | Research

Comments are closed
Copyright © 2001-2010 MS Consulting, Inc. All Rights Reserved.