473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

xml serialize properties

I am having a problem serializing an object. I have a very simple
class.

[Serializable]
public class Phone : SwcDomainObject
{
private string areaCode;
private string prefix;
private string suffix;
private string extension;

public string AreaCode
{
get { return areaCode; }
set { areaCode = value; }
}

public string Prefix
{
get { return prefix; }
set { prefix = value; }
}

public string Suffix
{
get { return suffix; }
set { suffix = value; }
}

public string Extension
{
get { return extension; }
set { extension = value; }
}

public string FullPhone
{
get{return this.areaCode + " " + this.prefix + " " + this.suffix;}
}

}
OUTPUT:
<PhoneWork>
<AreaCode>252</AreaCode>
<Prefix>332</Prefix>
<Suffix>4117</Suffix>
</PhoneWork>

Everything serializes fine except for the FullPhone Accessor. When
that serializes it doesn't hold the value in the xml document. I can
only assume since you are using the xml serialization as more of a
state holder. That function accesors are not serialized only static
primitive datatypes? Is there anyway I can force the serialization to
occur on this accessor?

TIA

JoSkillz

Nov 12 '05 #1
1 1099
Never mind I figured it out. In order for any of the object properties
to be serialized in XML they must expose both a setter and getter.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mudit | last post by:
Hi, I am new to XML Serialization. I am interested in serializing my object to Xml. I only have to serialize and I needn't worry about deserialization. As per my understanding, only the...
3
by: Peter Cresswell | last post by:
Hello everyone, I would like to serialize an object to XML. Currently my code will serialize all of the public properties that are value types, but not my public properties that have get...
7
by: grwalker | last post by:
I have some classes that have the <Serializable()> attribute applied, which of course by default serializes the class properties as elements. What I would like to do is to be able to override this...
0
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
1
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
10
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName;...
3
by: MAY | last post by:
Hi, I have a problem about serialize the form controls. I wrote a test program to test serialize a from but fail (->An unhandled exception of type...
8
by: cd~ | last post by:
I can provide a test app, the news server won't allow me to post the files because they are too large (93KB and 1.2KB) I downloaded the ESRI ArcXml schema and generated the classes from the...
2
by: Beorne | last post by:
I'm serializing a big class using XmlSerializer (I need xml serialization cause compact framework). I've learn that all my fields must be public. Ok. Now it is completly useless to serialize my...
4
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.