Skip to main content
added 297 characters in body
Source Link
Lee
  • 4k
  • 12
  • 49
  • 66

I get these errors when I try to XML serialize an array of lists.

Unable to generate a temporary class (result=1). error CS1026: ) expected error CS1002: ; expected ... error CS1525: Invalid expression term ')' error CS1002: ; expected

Here's my code:

This is the method that triggers the exception.

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();
    }
}

And this is the var passed to it:

List<Transaction>[] allTransactions = new List<Transaction>[20];

Thanks for any help.

[UPDATE]

public class TransactionCollection
{
    public List<Transaction>[] transactions;

    public TransactionCollection()
    {
    }

    public void Set(List<Transaction>[] t)
    {
        transactions = t;
    }
}

I get these errors when I try to XML serialize an array of lists.

Unable to generate a temporary class (result=1). error CS1026: ) expected error CS1002: ; expected ... error CS1525: Invalid expression term ')' error CS1002: ; expected

Here's my code:

This is the method that triggers the exception.

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();
    }
}

And this is the var passed to it:

List<Transaction>[] allTransactions = new List<Transaction>[20];

Thanks for any help.

I get these errors when I try to XML serialize an array of lists.

Unable to generate a temporary class (result=1). error CS1026: ) expected error CS1002: ; expected ... error CS1525: Invalid expression term ')' error CS1002: ; expected

Here's my code:

This is the method that triggers the exception.

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();
    }
}

And this is the var passed to it:

List<Transaction>[] allTransactions = new List<Transaction>[20];

Thanks for any help.

[UPDATE]

public class TransactionCollection
{
    public List<Transaction>[] transactions;

    public TransactionCollection()
    {
    }

    public void Set(List<Transaction>[] t)
    {
        transactions = t;
    }
}
Source Link
Lee
  • 4k
  • 12
  • 49
  • 66

How can I XML serialize an array of object lists?

I get these errors when I try to XML serialize an array of lists.

Unable to generate a temporary class (result=1). error CS1026: ) expected error CS1002: ; expected ... error CS1525: Invalid expression term ')' error CS1002: ; expected

Here's my code:

This is the method that triggers the exception.

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();
    }
}

And this is the var passed to it:

List<Transaction>[] allTransactions = new List<Transaction>[20];

Thanks for any help.