[dba-VB] C# serialization

Charlotte Foust cfoust at infostatsystems.com
Tue Oct 13 09:54:36 CDT 2009


John,

I'm not sure I understand what you're doing.  Do these classes inherit
typed datasets?  If so, the parent class can easily return a child class
that already contains a typed dataset of child records.  You don't
actually need collections for that.  In that case, grade wouldn't need
to be a class (although it could be, I just don't see any need).  The 

Charlotte Foust  

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Monday, October 12, 2009 7:35 PM
To: VBA
Subject: [dba-VB] C# serialization

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