Binary Serialization[highly automated]
Two ways to make type Binary Serializable
{if you want to serialize in XML this is not what you want}
implementing ISerializable gives you total control over the serialization
OR
Use attributes like serialzable,nonSerialized and various other attributes.
Using serialzable attribute instructs the serializer to include all fields in the type including private,publicbut notproperties`
XML Serialization[less automated]
I guess you want to serialize the class in XML,in that case
Two ways to make type XML Serializable
use System.Xml.Serialization attributes
OR
implement IXmlSerializer for more control
Your Question
is it important to use [Serializable()] in the beginning of class
(after namespace and before class) when we are dealing with
serialization
Ofcorse..This is how you are going to tell the compiler to serialize those particular types.But you should use the attributes or interface according to what the class should serialize to.
So,using [Serializable()] attribute for serializing the type to XML would not work.It is used for Binary Serialization.You should sprinkle attributes of System.Xml.Serialization attributes over the class or use IXmlSerializer for XML-serialization
You can use
1>Data Contract Serializer
2>Binary Serializer
3>Xml Serializer