Click here to Skip to main content
15,923,006 members
Home / Discussions / C#
   

C#

 
AnswerRe: Where to get started Pin
Richard MacCutchan11-May-10 22:27
mveRichard MacCutchan11-May-10 22:27 
AnswerRe: Where to get started Pin
crosson12-May-10 10:51
crosson12-May-10 10:51 
AnswerRe: Where to get started Pin
Ravi Sant14-Apr-11 1:22
Ravi Sant14-Apr-11 1:22 
QuestionSerialization Question Pin
Kevin Marois11-May-10 11:14
professionalKevin Marois11-May-10 11:14 
AnswerRe: Serialization Question Pin
William Winner11-May-10 11:40
William Winner11-May-10 11:40 
GeneralRe: Serialization Question Pin
Kevin Marois11-May-10 11:55
professionalKevin Marois11-May-10 11:55 
GeneralRe: Serialization Question Pin
William Winner11-May-10 12:07
William Winner11-May-10 12:07 
GeneralRe: Serialization Question Pin
Kevin Marois11-May-10 12:15
professionalKevin Marois11-May-10 12:15 
Thanks. Here's what I have from my test program. You code is at the bottom. The Xml file is empty after tnis runs:

static void Main(string[] args)
{
    // Create products
    Product p1 = new Product { ItemId = 100, ProductName = "Hammer" };
    Product p2 = new Product { ItemId = 101, ProductName = "Level" };
    Product p3 = new Product { ItemId = 102, ProductName = "Screwdriver" };

    // Create a Inv Detaild object and add the products to id
    InvoiceDetail details = new InvoiceDetail { ItemId = 10, InvoiceId = 4 };
    details.Items.Add(p1);
    details.Items.Add(p2);
    details.Items.Add(p3);

    // Create an Inv Header object and add the Inv Details to it
    InvoiceHeader ih = new InvoiceHeader { InvoiceDate = DateTime.Now };
    ih.Items.Add(details);

    // Create a customer and add the Inv Header to ir
    Customer customer = new Customer {ItemId = 1, Name = "Frank Jones" };
    customer.Items.Add(ih);

    // Create the customers collection and add the customer to it
    Customers customers = new Customers();
    customers.Items.Add(customer);

    // Serialize the collection
    string FileName = @"c:\myfile.xml";

    XmlSerializer serializer = null;

    try
    {
        serializer = new XmlSerializer(typeof(Test2.Customers));
    }
    catch (Exception ex)
    {  
        //do something
    }

    FileStream dataFile = new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.None);

    try
    {
        serializer.Serialize(dataFile, customers);
    }
    catch (Exception ex)
    {
        //do something
    }

    dataFile.Close();
    dataFile.Dispose();
}

Everything makes sense in someone's mind

GeneralRe: Serialization Question Pin
William Winner11-May-10 12:43
William Winner11-May-10 12:43 
GeneralRe: Serialization Question Pin
Kevin Marois11-May-10 12:54
professionalKevin Marois11-May-10 12:54 
GeneralRe: Serialization Question Pin
William Winner12-May-10 6:01
William Winner12-May-10 6:01 
GeneralRe: Serialization Question Pin
Kevin Marois12-May-10 6:39
professionalKevin Marois12-May-10 6:39 
AnswerRe: Serialization Question Pin
William Winner11-May-10 12:44
William Winner11-May-10 12:44 
Questioninternal keyword, InternalsAvailableTo Pin
Ryan Minor11-May-10 8:13
Ryan Minor11-May-10 8:13 
AnswerRe: internal keyword, InternalsAvailableTo Pin
Paulo Zemek11-May-10 9:41
Paulo Zemek11-May-10 9:41 
QuestionHow do I change service startup type Pin
ziopino7011-May-10 6:25
ziopino7011-May-10 6:25 
AnswerRe: How do I change service startup type Pin
#realJSOP11-May-10 6:30
professional#realJSOP11-May-10 6:30 
GeneralRe: How do I change service startup type Pin
ziopino7011-May-10 6:59
ziopino7011-May-10 6:59 
GeneralRe: How do I change service startup type Pin
PIEBALDconsult11-May-10 7:50
mvePIEBALDconsult11-May-10 7:50 
GeneralRe: How do I change service startup type Pin
Luc Pattyn11-May-10 7:54
sitebuilderLuc Pattyn11-May-10 7:54 
AnswerRe: How do I change service startup type Pin
Dimitri Witkowski11-May-10 10:01
Dimitri Witkowski11-May-10 10:01 
GeneralRe: How do I change service startup type Pin
Sunil G11-May-10 22:27
Sunil G11-May-10 22:27 
AnswerRe: How do I change service startup type Pin
Pete O'Hanlon11-May-10 22:44
mvePete O'Hanlon11-May-10 22:44 
AnswerRe: How do I change service startup type Pin
Sunil G11-May-10 23:07
Sunil G11-May-10 23:07 
QuestionWindowStartPosition Pin
gmhanna11-May-10 5:32
gmhanna11-May-10 5:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.