Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 819367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:17:50+00:00 2026-05-15T02:17:50+00:00

i am trying to XML serialize a class object but having the following problem:

  • 0

i am trying to XML serialize a class object but having the following problem:

the code compiles fine and the messagebox displays all the correct data but when i view the XML it does not seem to include the data for the actual transfer i.e. FireGridLocation data is missing from the XML.

        XmlSerializer s;
        StringWriter w;

        FireGridUnit fireGridUnit = new FireGridUnit();
        fireGridUnit.FireGridLocation = new GridUnit(GridLock.getColumn, GridLock.getRow);

        MessageBox.Show("gridlock col " + GridLock.getColumn);


        MessageBox.Show("column fire " + fireGridUnit.FireGridLocation.getColumn);
        MessageBox.Show("row fire " + fireGridUnit.FireGridLocation.getRow);

        s = new XmlSerializer(typeof(FireGridUnit));
        w = new StringWriter();
        s.Serialize(w, fireGridUnit);

        MessageBox.Show(w.ToString());

alt text http://img52.imageshack.us/img52/220/errorce.jpg

here is the FireGridUnit:

[Serializable]
public class FireGridUnit
{
    /// <summary>
    /// Location storage
    /// </summary>
    //public GridUnit FireGridLocation { get; set; }

    public GridUnit FireGridLocation;
}

and here is the GridUnit class:

public class GridUnit
{
    /// <summary>
    /// Default initialization
    /// </summary>
    public GridUnit()
    {
        Column = -1;
        Row = -1;
    }

    /// <summary>
    /// Initialize to supplied coordinate
    /// </summary>
    /// <param name="column"></param>
    /// <param name="row"></param>
    public GridUnit(int column, int row)
    {
        Column = column;
        Row = row;
    }

    /// <summary>
    /// Set/Return Column
    /// </summary>
    //public int Column { get; set; }

    private int Column;

    public int getColumn
    {
        get { return Column; }
    }

    /// <summary>
    /// Set/Return Row
    /// </summary>
    //public int Row { get; set; }

    private int Row;

    public int getRow
    {
        get { return Row; }
    }
}

if you can assist with this issue, your input is very welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:17:50+00:00Added an answer on May 15, 2026 at 2:17 am

    XML serialization can only serialize read/write properties. Your getColumn and getRow properties are read-only, so they can’t be serialized.

    BTW, the Serializable attribute is not necessary for XML serialization

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to serialize the following class into XML (in
I am trying to serialize my object to xml. A serializer seemingly serializes all
I'm trying to serialize the following object: [XmlRoot(book)] public class Book { #region Properties
I've been trying to serialize an XML (jQuery object) to string to POST it
I'm trying to serialize an object to XML that has a number of properties,
I'm trying to serialize into a Xml File an object which is declared as
I have an XML file that I'm trying to serialize into an object. Some
I've run into some problems when trying to serialize my object to XML. The
I am trying a write a program to serialize a object to a xml
I'm having this very odd issue while trying to serialize a class for logging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.