Struct serialization

Posted on 2006-05-23
Medium Priority
Last Modified: 2008-03-10
What do I need to make a struct serializable? Do I need to derrive from ISerializable?

Question by:gromul
LVL 44

Assisted Solution

bruintje earned 800 total points
ID: 16746933
Hi gromul,

you need to add the [Serializable] attrribute like

  public struct MyAccount {
    public int AccountNumber;
    public string CustomerName;
    public float Balance;

for more details
source: http://msdn2.microsoft.com/en-us/library/system.serializableattribute.aspx
source: http://my.execpc.com/~gopalan/dotnet/ado_net/ado.net_dataset_server_bookkeeper.html

share what you know, learn what you don't
LVL 13

Accepted Solution

devsolns earned 1200 total points
ID: 16747141
As far as implementeting ISerializable it depends.  The Serializable() attribute is for xml serialization which by default will only serialize public fields.  If you need to serialize private members then that is when you implement ISerializable.  However with custom serialization your only left with SoapFormatting or BinaryFormatting.  There is an IXmlSeriazable interface but its marked as "do not use" from Microsoft which means it could change and is unsupported.

Author Comment

ID: 16748019

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question