Imports System Imports System.IO Imports System.Runtime.Serialization.Formatters.Soap Imports CenterSpace.NMath.Core Namespace CenterSpace.NMath.Examples.VisualBasic A .NET example in Visual Basic showing how to serialize and deserialize an NMath object in SOAP format. Module SoapSerializationExample Private filename As String = "data.xml" Sub Main() Console.WriteLine() Delete old file, if it exists If (File.Exists(filename)) Then Console.WriteLine("Deleting old file") File.Delete(filename) End If Create vector Dim u As New DoubleVector("[ 5.6 4.2 5.4 -0.004 434 ]") Persist to file Dim stream As FileStream = File.Create(filename) Dim formatter As New SoapFormatter() Console.WriteLine("Serializing vector") formatter.Serialize(stream, u) stream.Close() Restore from file stream = File.OpenRead(filename) Console.WriteLine("Deserializing vector") Dim v As DoubleVector = formatter.Deserialize(stream) stream.Close() Console.WriteLine() Console.WriteLine("Press Enter Key") Console.Read() End Sub End Module End Namespace← All NMath Code Examples