Работа с классом: сериализация объекта - C#
Формулировка задачи:
Здравствуйте. Решил попробовать сериализовать объект.
и тут выдает мне ошибку в этом месте response1.result.resultID. не понимаю почему и экземпляр класса создавал. Что не правильно я сделал?
Листинг программы
- SendDocumentResponse response1 = new SendDocumentResponse();
- response1.result.resultID = 1;
- response1.result.resultDescription = "ok";
- response1.envelopeId = 123654;
- response1.confirmReceipt.ReceiptId = "1";
- response1.confirmReceipt.ReceiptText = "frgthyjkjhgfg";
- response1.confirmReceipt.receiptSignature.signedElements = "ertrytjuk";
- response1.confirmReceipt.receiptSignature.signatureType = "rgtfg";
- byte[] bytes = new byte[454215];
- response1.confirmReceipt.receiptSignature.signatureValue = bytes;
- response1.confirmReceipt.receiptSignature.signedPubicCertificate = bytes;
- response1.confirmReceipt.receiptSignature.signedDate = null;
- SoapFormatter formatter = new SoapFormatter();
- using (FileStream fs = new FileStream("out.xml", FileMode.OpenOrCreate))
- {
- formatter.Serialize(fs, response1);
- }
Листинг программы
- public class SendDocumentResponse
- {
- //public SendDocumentResponse() { result = new Result(); }
- //{ _result = new Result(); }
- private Result _result;
- private long _envelopeId;
- private ConfirmReceipt _confirmReceipt;
- /// <value>Property <c>result</c> Ответ.</value>
- public Result result{
- get { return this._result; }
- set { this._result = value; }
- }
- /// <value>Property <c>envelopeId</c>Номер зарегистрированного документа в Интеграционном шлюзе
- /// (по этому номеру необходимо выполнять запрос по статусу и на получение докумена)</value>
- public long envelopeId
- {
- get { return this._envelopeId; }
- set { this._envelopeId = value; }
- }
- /// <value>Property <c>confirmReceipt</c> Рецепт ответа.</value>
- public ConfirmReceipt confirmReceipt
- {
- get { return this._confirmReceipt; }
- set { this._confirmReceipt = value; }
- }
- }
Листинг программы
- public class Result
- {
- //public Result() { }
- private int resultIdC;
- private string resultDescriptionC;
- /// <value>Property <c>resultId</c> код возврата.</value>
- public int resultID
- {
- get { return this.resultIdC; }
- set { this.resultIdC = value; }
- }
- /// <value>Property <c>resultDescription</c> Описание ответа.</value>
- public string resultDescription
- {
- get { return this.resultDescriptionC; }
- set { this.resultDescriptionC = value; }
- }
- }
Решение задачи: «Работа с классом: сериализация объекта»
textual
Листинг программы
- result = new Result();
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д