M
mp
this example comes from msdn
http://msdn.microsoft.com/en-us/library/dsh84875.aspx
i notice they don't close filestream
is that ok?
private void DeserializeObject(string filename)
{
Console.WriteLine("Reading with Stream");
// Create an instance of the XmlSerializer.
XmlSerializer serializer =
new XmlSerializer(typeof(OrderedItem));
// Reading the XML document requires a FileStream.
Stream reader= new FileStream(filename,FileMode.Open);
// Declare an object variable of the type to be deserialized.
OrderedItem i;
// Call the Deserialize method to restore the object's state.
i = (OrderedItem) serializer.Deserialize(reader);
// Write out the properties of the object.
Console.Write(
i.ItemName + "\t" +
i.Description + "\t" +
i.UnitPrice + "\t" +
i.Quantity + "\t" +
i.LineTotal);
}
i also notice most samples don't null objects after use
is it ok to just let scope take care of destroying reference?
thanks
mark
http://msdn.microsoft.com/en-us/library/dsh84875.aspx
i notice they don't close filestream
is that ok?
private void DeserializeObject(string filename)
{
Console.WriteLine("Reading with Stream");
// Create an instance of the XmlSerializer.
XmlSerializer serializer =
new XmlSerializer(typeof(OrderedItem));
// Reading the XML document requires a FileStream.
Stream reader= new FileStream(filename,FileMode.Open);
// Declare an object variable of the type to be deserialized.
OrderedItem i;
// Call the Deserialize method to restore the object's state.
i = (OrderedItem) serializer.Deserialize(reader);
// Write out the properties of the object.
Console.Write(
i.ItemName + "\t" +
i.Description + "\t" +
i.UnitPrice + "\t" +
i.Quantity + "\t" +
i.LineTotal);
}
i also notice most samples don't null objects after use
is it ok to just let scope take care of destroying reference?
thanks
mark