A chunk of code.... and two questions follow.
public class myNode : TreeNode
public myNode(String name): base(name)
i = 99;
public new object Clone()
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
// Serialize the object into the stream.
//Position streem pointer back to first byte.
// Deserialize into another object.
myNode cloneObject = (myNode)bf.Deserialize(ms);
// Release memory.
public class myNode2 : myNode
public myNode2(String name): base(name)
If I change "new" to "override" in the myNode.Clone() function, then at deserialization, I get the exception :
"An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: The constructor to deserialize an object of type WindowsApplication1.myNode2 was not found."
Is there a reason I shouldn't use "new" here?
Why do I have to have a parameterless constructor in each of my classes? removing one throws :
An unhandled exception of type 'System.MissingMethodException' occurred in mscorlib.dll
Additional information: No parameterless constructor defined for this object.