using System.Collections.Generic;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO.Compression;
public partial class ct_ServiceProductInfoWireless
private WirelessItemBase[] itemsField;
[System.Xml.Serialization.XmlElementAttribute("NewWirelessLines", typeof(ct_WirelessLines))]
[System.Xml.Serialization.XmlElementAttribute("WirelessLine", typeof(ct_ServiceProductInfoWirelessWirelessLine))]
public WirelessItemBase[] Items {
public abstract class WirelessItemBase
public partial class ct_WirelessLines : WirelessItemBase
public partial class ct_ServiceProductInfoWirelessWirelessLine : WirelessItemBase
static string GetXml<T>(T objectToSerialize)
var stringWriter = new System.IO.StringWriter();
var serializer = new XmlSerializer(objectToSerialize.GetType());
serializer.Serialize(stringWriter, objectToSerialize);
return stringWriter.ToString();
static IEnumerable<ct_WirelessLines> GetWirelessLines()
return new [] { new ct_WirelessLines() };
static IEnumerable<ct_ServiceProductInfoWirelessWirelessLine> GetProductInfoWirelessWirelessLines()
return new [] { new ct_ServiceProductInfoWirelessWirelessLine() };
public static void Test()
var objectToSerialize = new ct_ServiceProductInfoWireless
Items = new [] { new [] { new ct_WirelessLines() } },
var xml = GetXml(objectToSerialize);
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.CodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];
I was able to get the error message `System.InvalidOperationException: The type ct_WirelessLines[] may not be used in this context.` by assigning `ct_ServiceProductInfoWireless.Items` to be an array of array of `ct_WirelessLines` instead of a 1d array: `Items = new [] { new [] { new ct_WirelessLines() } }`. Demo fiddle: https: