![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is serialization in C#.NET?
Serialization converts objects into a byte stream and brings it to a form that it can be written on stream. This is done to save it to memory, file or database.
Serialization can be performed as −
Binary Serialization
All the members, even members that are read-only, are serialized.
XML Serialization
It serializes the public fields and properties of an object into XML stream conforming to a specific XML Schema definition language document.
Let us see an example. Firstly set the stream −
FileStream fstream = new FileStream("d:\
ew.txt", FileMode.OpenOrCreate); BinaryFormatter formatter=new BinaryFormatter();
Now create an object of the class and call the constructor which has three parameters −
Employee emp = new Employee(030, "Tom", “Operations”);
Perform serialization −
formatter.Serialize(fStream, emp);
Advertisements