Click here to Skip to main content
15,891,864 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can I make a method abstract in a child class? Pin
Alan N3-May-09 13:46
Alan N3-May-09 13:46 
GeneralRe: How can I make a method abstract in a child class? Pin
Meysam Mahfouzi3-May-09 18:24
Meysam Mahfouzi3-May-09 18:24 
GeneralRe: How can I make a method abstract in a child class? Pin
Alan N3-May-09 23:47
Alan N3-May-09 23:47 
GeneralRe: How can I make a method abstract in a child class? Pin
Meysam Mahfouzi4-May-09 2:22
Meysam Mahfouzi4-May-09 2:22 
GeneralRe: How can I make a method abstract in a child class? Pin
Alan N4-May-09 3:26
Alan N4-May-09 3:26 
GeneralRe: How can I make a method abstract in a child class? Pin
Meysam Mahfouzi4-May-09 4:05
Meysam Mahfouzi4-May-09 4:05 
GeneralRe: How can I make a method abstract in a child class? Pin
Alan N4-May-09 4:41
Alan N4-May-09 4:41 
QuestionUrgent Help With Serialization needed Pin
GrgBalden3-May-09 11:46
GrgBalden3-May-09 11:46 
Hi,

I'm new to the world of .Net and C#. I need some help with serialization:

I'm trying to serialize an object to an XML file, this object has a nested class which I also want to serialize:

[Serializable]
    public class NewOrder
    {
        //constructor
        public NewOrder()
        {
        }

        //Destructor
        ~NewOrder()
        {
        }
        private string accountGroupfield;
        private string accountNumberfield;

        public string AccountGroup
        {
            get
            {
                return accountGroupfield;
            }
            set
            {
                accountGroupfield = value;
            }
        }

        
        public string AccountNumber
        {
            get
            {
                return accountNumberfield;
            }
            set
            {
                accountNumberfield = value;
            }
        }

[Serializable]
public class CardDetail
        {
                   

            private string cardFirstNamefield;
            private string cardLastNamefield;
            private string cardNumberfield;

            public string CardFirstName
            {
                get
                {
                    return cardFirstNamefield;
                }
                set
                {
                    cardFirstNamefield = value;
                }
            }

            
           
            public string CardLastName
            {
                get
                {
                    return cardLastNamefield;
                }
                set
                {
                    cardLastNamefield = value;
                }
            }

            public string CardNumber
            {
                get
                {
                    return cardNumberfield;
                }
                set
                {
                    cardNumberfield = value;
                }
            }

 }

I have a function to serialize the object but all I get in the Xml file is:

<?xml version="1.0"?>
<NewOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <AccountGroup>100</AccountGroup>
  <AccountNumber>66302</AccountNumber>
</NewOrder>


I've been searching around the internet for days now, but I still havent managed to get the nested class output as a nested element within the XML.

Apologies for rambling, the output to the XML I'm looking for is as follows:

<?xml version="1.0"?>
<NewOrder  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <AccountGroup>100</AccountGroup>
  <AccountNumber>66302</AccountNumber>
  <CardDetail>
        <CardFirstName>George</CardFirstName>
        <CardSurname>Balden</CardSurname>
        <CardNumber>6123 2222 4444 6666</CardNumber>
  </CardDetail>
</NewOrder>

AnswerRe: Urgent Help With Serialization needed Pin
Henry Minute3-May-09 12:39
Henry Minute3-May-09 12:39 
QuestionRe: Urgent Help With Serialization needed Pin
GrgBalden3-May-09 23:10
GrgBalden3-May-09 23:10 
AnswerRe: Urgent Help With Serialization needed Pin
Henry Minute4-May-09 1:33
Henry Minute4-May-09 1:33 
GeneralRe: Urgent Help With Serialization needed Pin
GrgBalden4-May-09 3:09
GrgBalden4-May-09 3:09 
GeneralRe: Urgent Help With Serialization needed Pin
Henry Minute4-May-09 4:10
Henry Minute4-May-09 4:10 
QuestionNeed some help fast:D [modified] Pin
DrJele3-May-09 7:32
DrJele3-May-09 7:32 
AnswerRe: Need some help fast:D Pin
Henry Minute3-May-09 8:46
Henry Minute3-May-09 8:46 
GeneralRe: Need some help fast:D Pin
Member 10339073-May-09 10:43
Member 10339073-May-09 10:43 
GeneralRe: Need some help fast:D Pin
DrJele4-May-09 10:29
DrJele4-May-09 10:29 
GeneralRe: Need some help fast:D Pin
Member 10339074-May-09 20:55
Member 10339074-May-09 20:55 
Questionerror using float for array to string Pin
onetreeup3-May-09 7:26
onetreeup3-May-09 7:26 
AnswerRe: error using float for array to string Pin
fly9043-May-09 8:06
fly9043-May-09 8:06 
QuestionAcess control system for company entrance Pin
7alool3-May-09 4:41
7alool3-May-09 4:41 
AnswerRe: Acess control system for company entrance Pin
PIEBALDconsult3-May-09 5:43
mvePIEBALDconsult3-May-09 5:43 
AnswerRe: Acess control system for company entrance Pin
Dave Kreskowiak3-May-09 6:39
mveDave Kreskowiak3-May-09 6:39 
QuestionPrinter on distributed system Pin
Snappy Wing3-May-09 4:39
Snappy Wing3-May-09 4:39 
AnswerRe: Printer on distributed system Pin
Dave Kreskowiak3-May-09 6:40
mveDave Kreskowiak3-May-09 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.