By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,900 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,900 IT Pros & Developers. It's quick & easy.

Singleton (XML) serialization

P: n/a
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;
}
}
}


Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Nov 15 '05 #2

P: n/a
Yes, you have.

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

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Arjen" <bo*****@hotmail.com> wrote in message news:bv**********@news1.tilbu1.nb.home.nl...
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

Nov 15 '05 #3

P: n/a
Thanks for your link and support!

It finally works! (YESSS)

Thanks,
Arjen


"Cezary Nolewajka" <c.*********************@no-sp-am-eh-mail.com> schreef in
bericht news:us**************@TK2MSFTNGP11.phx.gbl...
Yes, you have.

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

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Arjen" <bo*****@hotmail.com> wrote in message
news:bv**********@news1.tilbu1.nb.home.nl...
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

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.