Deserialize to self

前端 未结 4 600
灰色年华
灰色年华 2021-01-11 18:08

Ok, I\'m probably just having an epic fail here, but my mind wants to say this should work.

Assume DataProtect.DecryptData takes an encrypted string as input and a d

4条回答
  •  花落未央
    2021-01-11 18:23

    No, this is not possible using a constructor, you can't reassign this.

    Use a static method instead:

    public static ArrivedDetails CreateFromString(string encrypted)
    {
        return DataProtect.deserializeXML(DataProtect.DecryptData(encrypted));
    }
    

    Call it:

    ArrivedDetails details = ArrivedDetails.CreateFromString(encrypted);
    

提交回复
热议问题