[dba-VB] C# serialization

jwcolby jwcolby at colbyconsulting.com
Mon Oct 12 21:35:07 CDT 2009


I have a homework project in which I collect grades in clsgrade instances, in collection in 
clsGrades instances.  I need to serialize / deserialize the clsGrade instances in the collection in 
each clsGrades instance.

I actually did this a year or so ago in VB.Net but am not finding anything that results in a similar 
structure in c#.  I managed to serialize a bunch but the results looked like:

<?xml version="1.0" encoding="utf-8"?>

<clsGrade xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <Grade>100</Grade>
   <GradeType>1</GradeType>
</clsGrade><?xml version="1.0" encoding="utf-8"?>

<clsGrade xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <Grade>99</Grade>
   <GradeType>1</GradeType>
</clsGrade><?xml version="1.0" encoding="utf-8"?>


As you can see I am getting a ton of header crap for each grade.  I don't even have the code any more.

Does anyone have simple code for serializing a strongly typed list full of class instances without 
serializing each instance manually?  Then wrapping that in a higher level as well (the supervisor 
clsGrades)?

TIA

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-VB mailing list