Explicitly Calling Variable Initailzers on uninitalized Object?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tsteinke@gmail.com

    Explicitly Calling Variable Initailzers on uninitalized Object?

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

    for instance

    Class A
    {
    private int a=123;
    }

    object shell=Formatter Services.GetUni nitializedObjec t(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

  • Jon Skeet [C# MVP]

    #2
    Re: Explicitly Calling Variable Initailzers on uninitalized Object?

    <tsteinke@gmail .com> wrote:[color=blue]
    > Doe anyone know the way to explicitly call the varible initializers on
    > an object?
    >
    > for instance
    >
    > Class A
    > {
    > private int a=123;
    > }
    >
    > object shell=Formatter Services.GetUni nitializedObjec t(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[/color]

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

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...