This code demonstrates how to serialize and deserialize an ArrayXf object to/from a file. The code creates a 2D array of size 4x2, fills it with float values and writes it to a file. It then reads the data back and prints the content of the array.
using System;
{
public class SerializeArray
{
static void SerializeArrayXf()
{
string tmpFilePath = System.IO.Path.GetTempPath() + "serialization_array_net.txt";
Console.WriteLine("Serialize array into " + tmpFilePath);
if (dst == null)
{
throw new Exception("Impossible to open file " + tmpFilePath);
}
dst = null;
if (src == null)
{
throw new Exception("Impossible to open file " + tmpFilePath);
}
Console.WriteLine(
"Content of unserialized array:" + arrayRead.
ToString());
}
public static void Main(string[] args)
{
SerializeArrayXf();
Console.WriteLine("SUCCESS");
}
}
}
A multi dimensionnal array.
Definition ArrayXf.cs:27
string ToString()
Return a string representation.
Definition ArrayXf.cs:193
void SetAt(VectorXu64 index, float value)
Set a value to an element of the array.
Definition ArrayXf.cs:180
Serialization class which provides methods to serialize and unserialize most of IOLink objects.
Definition Serialization.cs:15
A factory to create StreamAccess instances from various ressources.
Definition StreamAccessFactory.cs:14
static StreamAccess OpenFileRead(string filePath)
Create a stream that can read data from a file.
Definition StreamAccessFactory.cs:106
static StreamAccess OpenFileWrite(string filePath)
Create a stream that can write data to a file.
Definition StreamAccessFactory.cs:116
Mother interface for all stream-like data accessors.
Definition StreamAccess.cs:20
virtual void Flush()
Assure that all data is written to the endpoint.
Definition StreamAccess.cs:168
A dynamically sized arithmetic vector.
Definition VectorXu64.cs:14
Definition CreateDataFrame.cs:6
Definition AccessCapabilities.cs:11