Hi everybody!

I am having the same problem as "jamessadlier" had in the following thread:
thtp://www.codeguru.com/forum/showthread.php?t=348850

The error i get while trying to serialize is the same expect with another type of collection (LinkedList).
{"You must implement a default accessor on System.Collections.Generic.LinkedList because it inherits from ICollection."}

"jamessadlier" solved his own problem and said:
Fixed it. The Keyword "Default" has to be on the declaration of the accessor.
That is VB .net, but what would the C# equivalent?

I suspect that it is the c# keyword default? http://msdn.microsoft.com/en-us/libr...0d(VS.80).aspx


i tried to serialize MyLinkedList (code, see below), which i created by extending LinkedList. The problem is the same no matter wheter i use MyLinkedList or LinkedList.

now some code:

Class MyLinkedList.cs
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace Example
{
    public class MyLinkedList<T> : LinkedList<T>
{

        
        new public void AddLast(T value)
{
            base.AddLast(value);
            SetFlags();
}
        new public void AddFirst(T value)
{
            base.AddFirst(value);
            SetFlags();
}
        new public void AddLast(LinkedListNode<T> node)
{
            base.AddLast(node);
            SetFlags();
}
        new public void AddFirst(LinkedListNode<T> node)
{
            base.AddFirst(node);
            SetFlags();
}
        new public void AddAfter(LinkedListNode<T> node, LinkedListNode<T> newNode)
{
            base.AddAfter(node, newNode);
            SetFlags();
}
        new public void AddAfter(LinkedListNode<T> node, T value)
{
            base.AddAfter(node, value);
            SetFlags();
}
        new public void AddBefore(LinkedListNode<T> node, LinkedListNode<T> newNode)
{
            base.AddBefore(node, newNode);
            SetFlags();
}
        new public void AddBefore(LinkedListNode<T> node, T value)
{
            base.AddBefore(node, value);
            SetFlags();
}
        new public void Clear()
{
            base.Clear();
            SetFlags();
}
        new public void Remove(T value)
{
            base.Remove(value);
            SetFlags();
}
        new public void Remove(LinkedListNode<T> node)
{
            base.Remove(node);
            SetFlags();
}
        new public void RemoveFirst()
{
            base.RemoveFirst();
            SetFlags();
}
        new public void RemoveLast()
{
            base.RemoveLast();
            SetFlags();
}

        private void SetFlags()
{
            //some stuff here
}
}
}
and the class containing MyLinkedList or LinkedList ( the one i want to serialize, its just the relevant part):

Settings.cs
Code:
public class UserSettings : XMLPersistence<UserSettings>
{

        public UserSettings()
{
    //some stuff here
}

        
//some properties (primitive types here)
        private MyLinkedList<DayOfWeek> _workdays;

        public MyLinkedList<DayOfWeek> Workdays
{
            get { return _workdays;  } 
            set { _workdays = value; }
}

//some properties (primitive types here)
}
and XMLPersistence.cs

Code:
    public class XMLPersistence<T>
    {

        public static T Deserialize(string sPath)
        {
            XmlSerializer ser = new XmlSerializer(typeof(T));
            StreamReader str = new StreamReader(sPath);
            T to_read = (T)ser.Deserialize(str);
            str.Close();
            return to_read;
        }

        public void Serialize(string sPath)
        {
            XmlSerializer ser = new XmlSerializer(typeof(T));
            FileStream str = new FileStream(sPath, FileMode.Create);
            ser.Serialize(str, this);
            str.Close();
        }
    }
so a short "test"-program could look like:
Code:
            UserSettings cl1 = new UserSettings();
            //fill cl1 with values
            cl1.Serialize("C:\\test.xml");
So what do i need to change t omake that example fly?

it would be grat if someone would point me into the right direction. i hope this question is not too foolish. Thank in advance for your help!!

Cheers!