Работа с классом: сериализация объекта - C#

Узнай цену своей работы

Формулировка задачи:

Здравствуйте. Решил попробовать сериализовать объект.
Листинг программы
  1. SendDocumentResponse response1 = new SendDocumentResponse();
  2. response1.result.resultID = 1;
  3. response1.result.resultDescription = "ok";
  4. response1.envelopeId = 123654;
  5. response1.confirmReceipt.ReceiptId = "1";
  6. response1.confirmReceipt.ReceiptText = "frgthyjkjhgfg";
  7. response1.confirmReceipt.receiptSignature.signedElements = "ertrytjuk";
  8. response1.confirmReceipt.receiptSignature.signatureType = "rgtfg";
  9. byte[] bytes = new byte[454215];
  10. response1.confirmReceipt.receiptSignature.signatureValue = bytes;
  11. response1.confirmReceipt.receiptSignature.signedPubicCertificate = bytes;
  12. response1.confirmReceipt.receiptSignature.signedDate = null;
  13. SoapFormatter formatter = new SoapFormatter();
  14. using (FileStream fs = new FileStream("out.xml", FileMode.OpenOrCreate))
  15. {
  16. formatter.Serialize(fs, response1);
  17. }
и тут выдает мне ошибку в этом месте response1.result.resultID. не понимаю почему и экземпляр класса создавал. Что не правильно я сделал?
Листинг программы
  1. public class SendDocumentResponse
  2. {
  3. //public SendDocumentResponse() { result = new Result(); }
  4. //{ _result = new Result(); }
  5. private Result _result;
  6. private long _envelopeId;
  7. private ConfirmReceipt _confirmReceipt;
  8. /// <value>Property <c>result</c> Ответ.</value>
  9. public Result result{
  10. get { return this._result; }
  11. set { this._result = value; }
  12. }
  13. /// <value>Property <c>envelopeId</c>Номер зарегистрированного документа в Интеграционном шлюзе
  14. /// (по этому номеру необходимо выполнять запрос по статусу и на получение докумена)</value>
  15. public long envelopeId
  16. {
  17. get { return this._envelopeId; }
  18. set { this._envelopeId = value; }
  19. }
  20. /// <value>Property <c>confirmReceipt</c> Рецепт ответа.</value>
  21. public ConfirmReceipt confirmReceipt
  22. {
  23. get { return this._confirmReceipt; }
  24. set { this._confirmReceipt = value; }
  25. }
  26. }
Листинг программы
  1. public class Result
  2. {
  3. //public Result() { }
  4. private int resultIdC;
  5. private string resultDescriptionC;
  6. /// <value>Property <c>resultId</c> код возврата.</value>
  7. public int resultID
  8. {
  9. get { return this.resultIdC; }
  10. set { this.resultIdC = value; }
  11. }
  12. /// <value>Property <c>resultDescription</c> Описание ответа.</value>
  13. public string resultDescription
  14. {
  15. get { return this.resultDescriptionC; }
  16. set { this.resultDescriptionC = value; }
  17. }
  18. }

Решение задачи: «Работа с классом: сериализация объекта»

textual
Листинг программы
  1. result = new Result();

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

15   голосов , оценка 4.067 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы