How can I XML serialize an array of object lists?

Arch Gothic

New Member
I get these errors when I try to XML serialize an array of lists.\[quote\] Unable to generate a temporary class (result=1). error CS1026: ) expected error CS1002: ; expected ... error CS1525: Invalid expression term ')' error CS1002: ; expected\[/quote\]Here's my code:This is the method that triggers the exception.\[code\]public static string SerializeToString<T>(T obj){ XmlSerializer serializer = new XmlSerializer(typeof(T)); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, obj); return writer.ToString(); }}\[/code\]And this is the var passed to it:\[code\]List<Transaction>[] allTransactions = new List<Transaction>[20];\[/code\]Thanks for any help.[UPDATE]\[code\]public class TransactionCollection{ public List<Transaction>[] transactions; public TransactionCollection() { } public void Set(List<Transaction>[] t) { transactions = t; }}\[/code\]
 
Back
Top