XML Serialization : Arraylist of a Class
Posted on 2007-03-30
Hi, my name is John and I'm a VB.net 2005 Newbie. Here's my problem:
I'm creating a VB.net 2005 program that allows the user to build a sequence of machining operations. I have a class called cOperation, which contains all the parameters for a single CNC machining operation (Drill, Countour, or Pocket, ...etc.) I'm using an arraylist called OpList to contain each of machining operation defined in the Operation Class (cOperation).
<Serializable()> Public Class cOperation
Public OpName As String ' Name of Operation (Drill, Mill, PktRect, etc.)
Public Depth As Double ' Depth in z-axis for operation
Public MaxDepthCut As Double ' Maximum cutter depth per pass
Public ToolNo As Integer ' Tool Number in Magazine
Public Pts As New ArrayList ' Arraylist of Pts that define geometry or location to drill
Public Contour As New ArrayList ' Arraylist of contour class (line or arc with endpoints)
Public Radius As Double
Now, I want to save the list of machining operations to a text file. I've just stumbled upon XML serialization/deserialization. It seems to be perfect, but I can't get it to work. The examples I've found on the Web are either outdated or don't work.
Could someone please provide a simple example?