TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Michael O Donnell
NA
2
0
C# Serialization
Dec 3 2010 6:43 AM
Hi
This is more a question on best practices rather that a specific problem with Serialization. I've created a Person class with forename, surname, dob, mobile, email global variables and I've declared these variables as private. I've then added a property for each of the global variables so I can read them and update them as necessary. I've also create a function that calculates a persons age based on the current year and the year element from the dob variable.
I want to be able to serialize and deserialize my Person class using XML serialization. To do the serialization, I understand that all the variables must be public and that I need to create a parameterless constructor. Some of the reading that I've done recommend that the I should keep these global variables private and use properties to access and update the values.
Any suggestions on how I can allow serialization while at the same time comply with some common practices/standards? Do I have seperate copies of the Person class the lite version and the full version. Think I'd run into problems when I went to deserialize the XML in that scenario.
Regards
Michael.
Reply
Answers (
4
)
Fill DropDownBox with the data from excel
Navigating between controls on enter click in C#