Singleton (XML) serialization

A

Arjen

Hi there,

I have tried to run some samples without succes.
So I have made a new sample. Maybe someone can fix the serialization?

The class "MyProgram" must be saved to an xml file and placed back in the
program with the "open" call.

Hope someone can do something for me.
Thanks,
Arjen


// -------------------------------------------------------------------------



using System;
using System.Collections;

namespace MyProgram {

class MyProgram {

public static Hashtable Persons = new Hashtable();

[STAThread]
static void Main(string[] args) {
Open();

DoSomeThing();

Save();
}

static public void DoSomeThing() {

// New object
Person person = new Person("James", 12);

// Add to the hashtable
Persons.Add( person.GetHashCode(), person);
}


static void Open() {
// Read the serialization

}

static void Save() {
// Save the serialization

}
}

class Person {
string _name;
int _age;

public Person( string name, int age) {
_name = name;
_age = age;
}
}
}
 
A

Arjen

If I have serialized "class MyProgram" in a binary format then I have all
the information of private and public fields or not?

Something like this is what I must have.

Thanks,
Arjen
 
C

Cezary Nolewajka

Yes, you have.

BTW. I have sent a link to a serialization project in one of your other topics. Have a go at it.
 
A

Arjen

Thanks for your link and support!

It finally works! (YESSS)

Thanks,
Arjen






"Cezary Nolewajka" <[email protected]> schreef in
bericht Yes, you have.

BTW. I have sent a link to a serialization project in one of your other
topics. Have a go at it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top