473,385 Members | 1,930 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,385 software developers and data experts.

property serialisation get and set

Hi,

When I serialise a class to XML which has properties I sometimes have
properties that are like this -

public double SpeedMPH {
get {
return (double)Math.Round(windSpeed*2.23693629,2);
}
}

There is no set accessor for it but one must exist for serialisation to
occur. So I normally end writing a set that has something in it like

public double SpeedMPH {
get {
return (double)Math.Round(windSpeed*2.23693629,2);
}
set { int p=0xf; }
}

This is obviously not best practice, what is the solution?

Nov 12 '05 #1
2 1045
You could put an XmlIgnore attribute on it as it's not part of the
persistent state of the model but derived.

Paul

"gary" <gb*****@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi,

When I serialise a class to XML which has properties I sometimes have
properties that are like this -

public double SpeedMPH {
get {
return (double)Math.Round(windSpeed*2.23693629,2);
}
}

There is no set accessor for it but one must exist for serialisation to
occur. So I normally end writing a set that has something in it like

public double SpeedMPH {
get {
return (double)Math.Round(windSpeed*2.23693629,2);
}
set { int p=0xf; }
}

This is obviously not best practice, what is the solution?

Nov 12 '05 #2
It depends on how much coding you want to do. If you like to code then
implement IXmlSerializable.

gary wrote:
Hi,

When I serialise a class to XML which has properties I sometimes have
properties that are like this -

public double SpeedMPH {
get {
return (double)Math.Round(windSpeed*2.23693629,2);
}
}

There is no set accessor for it but one must exist for serialisation to
occur. So I normally end writing a set that has something in it like

public double SpeedMPH {
get {
return (double)Math.Round(windSpeed*2.23693629,2);
}
set { int p=0xf; }
}

This is obviously not best practice, what is the solution?

Nov 12 '05 #3

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

Similar topics

2
by: unknow | last post by:
I want to do a serialisation in pure C++ but i don't know how. Do you have some useful links ? Thanks
2
by: msnews.microsoft.com | last post by:
Hi Here is another EASY question When you serialise an object in .NET, serialisation adds defaut attributes that I dont care EXEMPLE : <root_test...
1
by: lobrys | last post by:
Hi everybody here is a question I have this class that a want to serialize : Public Class BOO <XmlAttributeAttribute()> Public THING As String <XmlElementAttribute("param")> Public p() As...
2
by: lobrys | last post by:
Hi everybody what are the objets for the folowing XML serialisation : (I have problem with "name" and "datatype") <vehicule type="car"> <name datatype="String">Megane</name> </inventory> ...
1
by: erez shalom | last post by:
Hi , i have : public classA { private int id; public int id{get...,set....) }
0
by: Mark Ingram | last post by:
Hi, ive got a custom control, it basically has a label and a toolstrip. i can add my control to the toolbox and add it to a form, but i'd really like to be able to let the end developer add items...
2
by: Greg | last post by:
I have a bizarre situation in which serialisation is failing routinely under a specific condition, and I'm wondering if the details ring a bell with anyone here. I have 2 classes that my...
2
by: ashwinij | last post by:
Hello The steps which i am doing in my program 1) I am having an xml file. 2) I am performing some updations in the file using XQueryUtil class from nux package. 3)After that i am...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.