ISerializable and SerializableAttribute

S

Steve B.

Hi,

If a class implements the ISerializable, does the class has the
SerializableAttribute "automatically" defined, and if a class has the
SerializableAttribute defined, does it implements the ISerializable
interface ?

Actually, I'd like to create a serialization utility that can serializable
any class that is serializable, without having to test at run time the
feasability.

For exemple, I'd like something like this :

public static void Serialize(ISerializable objectToSerialize, Stream output)
{
....
}

which works for both way of declaring a class serializable.

Thanks in advance,
Steve
 
M

Michael Nemtsev

Hello Steve B.,

If u don't mark you object with the [Serializable] attribute you got an expeption,
else if you do not implement ISerializable, default serialization is used
- serialize all fields that not marked as [NonSerialized]

S> Hi,
S>
S> If a class implements the ISerializable, does the class has the
S> SerializableAttribute "automatically" defined, and if a class has the
S> SerializableAttribute defined, does it implements the ISerializable
S> interface ?
S>
S> Actually, I'd like to create a serialization utility that can
S> serializable any class that is serializable, without having to test
S> at run time the feasability.
S>
S> For exemple, I'd like something like this :
S>
S> public static void Serialize(ISerializable objectToSerialize, Stream
S> output)
S> {
S> ...
S> }
S> which works for both way of declaring a class serializable.
S>
S> Thanks in advance,
S> Steve
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 

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