Abdul Salam

Abdul Salam

  • 1.7k
  • 88
  • 2.5k

Serialization Custom DataType

Jun 12 2019 1:40 AM

**I Convert XSD to c# Class now when i create object of class and assign a value am getting error

Cannot implicitly convert type 'int' to 'Frameworkgo.Envelope.IdentifierType

am doing serialization kindly help me on that

THANKYOU
  1. static void Main(string[] args)  
  2.     {  
  3.   
  4.         ObjectEnvelopeType objectenvelopetype = new ObjectEnvelopeType();  
  5.         objectenvelopetype.DocumentReference.DocumentID = 345;  
  6.   
  7.         XmlSerializer serializer = new XmlSerializer(typeof(ObjectEnvelopeType));  
  8.         FileStream fs = new FileStream("Object.xml", FileMode.Create);  
  9.         serializer.Serialize(fs, objectenvelopetype);  
  10.         fs.Close();  
  11.   
  12.         Console.ReadKey();  
  13.     }  
  14. public partial class ObjectEnvelopeType  
  15. {  
  16.  private ReferenceType documentReferenceField;  
  17.  public ReferenceType DocumentReference{get{return this.documentReferenceField;}set{documentReferenceField = value;}}  
  18. }  
  19.   
  20. public partial class ReferenceType  
  21. {  
  22.     private IdentifierType documentIDField;  
  23.     public IdentifierType DocumentID{get{return documentIDField;}set{documentIDField = value;}}   
  24. }  
  25. public partial class DocumentReferenceType  
  26. {  
  27.     private IdentifierType idField;  
  28.     public IdentifierType ID{get{return this.idField;}set{this.idField = value;}}  
  29. }  
  30. public partial class IdentifierType   
  31. {  
  32.     private string identificationSchemeIDField;  
  33.     [System.Xml.Serialization.XmlAttributeAttribute(DataType = "normalizedString")]  
  34.     public string identificationSchemeID{get{return this.identificationSchemeIDField;}set{this.identificationSchemeIDField = value;}}   
  35. }  
 

Answers (3)