Sjari

-
C# Tutorial - XML Serialization
08/06/2010 - 00:31
how to de-serialize it ?
-
C# Tutorial - XML Serialization
08/05/2010 - 09:01
Ah I found out that "class Class1" must be "public class Class1"
-
C# Tutorial - XML Serialization
08/05/2010 - 08:59
Hi, Thanks allot, that was extremely wonderful :-)
but the code does not run for me!
using System;
using System.IO;
using System.Xml.Serialization;
namespace XML007
{
class Class1
{
public class Movie
{
public string Title
{ get; set; }
public int Rating
{ get; set; }
public DateTime ReleaseDate
{ get; set; }
}
static void Main(string[] args)
{
Movie movie = new Movie();
movie.Title = "Starship Troopers";
movie.ReleaseDate = DateTime.Parse("11/7/1997");
movie.Rating = 6;
SerializeToXML(movie);
}
static public void SerializeToXML(Movie movie)
{
// I get erro in the line below, the class must be public, which it is !!!
XmlSerializer serializer = new XmlSerializer(typeof(Movie));
TextWriter textWriter = new StreamWriter(@"C:\movie.xml");
serializer.Serialize(textWriter, movie);
textWriter.Close();
}
}
}
Recent Comments