I am trying to save a collection of objects with XamlWriter
in the simplest way possible. For some reason saving them as an array produces invalid XML:
var array = new int[] {1, 2, 3};
Console.Write(XamlWriter.Save(array));
outputs:
<Int32[] xmlns="clr-namespace:System;assembly=mscorlib">
<Int32>1</Int32>
<Int32>2</Int32>
<Int32>3</Int32>
</Int32[]>
Attempting to read this using XamlReader
throws:
The '[' character, hexadecimal value 0x5B, cannot be included in a name. Line 1, position 7
I've tried saving as a List<T>
instead but I get the usual XAML generics error. Is there some simple way I can do it (preferably with LINQ) or do I have to define my own wrapper type?