This project has moved and is read-only. For the latest updates, please go here.

Deserialize Generic Stack Class

Oct 18, 2010 at 8:03 AM

I want to serialize / deserialize a Generic Stack object.

Serializing is no problem but when deserializing I get the following error ...

Cannot create and populate list type System.Collections.Generic.Stack`1[System.String].

Stack<string> stringStack = new Stack<string>();



string serializedStack = JsonConvert.SerializeObject(stringStack);

// this line errors

Stack<string> newStack = JsonConvert.DeserializeObject<Stack<string>>(serializedStack);

Am I doing something wrong?