Explicitly Calling Variable Initailzers on uninitalized Object?

  • Thread starter Thread starter tsteinke
  • Start date Start date
T

tsteinke

Doe anyone know the way to explicitly call the varible initializers on
an object?

for instance

Class A
{
private int a=123;
}

object shell=FormatterServices.GetUninitializedObject(typeof(A));

// Here is where I want to run the value initalizers to fill in a

I know the framework does this to initalize NonSerilized Fields during
deserilization.

Any help appreciated

Tom
 
Doe anyone know the way to explicitly call the varible initializers on
an object?

for instance

Class A
{
private int a=123;
}

object shell=FormatterServices.GetUninitializedObject(typeof(A));

// Here is where I want to run the value initalizers to fill in a

I know the framework does this to initalize NonSerilized Fields during
deserilization.

Any help appreciated

The initialisers only exist in the construtors as far as I'm aware, so
you really need to call a constructor.
 
Back
Top