Javatpoint.com is changed to TpointTech.com
C# SerializationIn C#, serialization is the process of converting object into byte stream so that it can be saved to memory, file or database. The reverse process of serialization is called deserialization. Serialization is internally used in remote applications. C# SerializableAttributeTo serialize the object, you need to apply SerializableAttribute attribute to the type. If you don't apply SerializableAttribute attribute to the type, SerializationException exception is thrown at runtime. C# Serialization exampleLet's see the simple example of serialization in C# where we are serializing the object of Student class. Here, we are going to use BinaryFormatter.Serialize(stream, reference) method to serialize the object. sss.txt: JConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Student rollnoname e sonoo As you can see, the serialized data is stored in the file. To get the data, you need to perform deserialization. Next TopicC# Deserialization |
Javatpoint.com is now changed to TpointTech.com, so we request you to subscribe our newsletter for further updates.
class is used to read string from the stream. It inherits TextReader class. It provides Read() and ReadLine() methods to read data from the stream. example to read one line Let's see the simple example of StreamReader class that reads a single line of data from...
2 min read
Class The FileInfo class is used to deal with file and its operations in C#. It provides properties and methods that are used to create, delete and read file. It uses StreamWriter class to write data to the file. It is a part of System.IO namespace. ...
6 min read
class is used to write characters to a stream in specific encoding. It inherits TextWriter class. It provides overloaded write() and writeln() methods to write data into file. example Let's see a simple example of StreamWriter class which writes a single line of data into the...
1 min read
class is used to write binary information into stream. It is found in System.IO namespace. It also supports writing string in specific encoding. Example Let's see the simple example of BinaryWriter class which writes data into dat file. using System; using System.IO; namespace BinaryWriterExample { class Program ...
1 min read
Class StringReader class is used to read data written by the StringWriter class. It is subclass of TextReader class. It enables us to read a string synchronously or asynchronously. It provides constructors and methods to perform read operations. Signature [SerializableAttribute] [ComVisibleAttribute(true)] public class StringReader : TextReader Constructors StringReader has the...
2 min read
class is an abstract class. It is used to write text or sequential series of characters into file. It is found in System.IO namespace. Example Let's see the simple example of TextWriter class to write two lines data. using System; using System.IO; namespace TextWriterExample { class Program ...
1 min read
In C# programming, deserialization is the reverse process of serialization. It means you can read the object from byte stream. Here, we are going to use BinaryFormatter.Deserialize(stream) method to deserialize the stream. Example Let's see the simple example of deserialization in C#. using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; [Serializable] class Student { ...
1 min read
Class This class is used to write and deal with string data rather than files. It is derived class of TextWriter class. The string data written by StringWriter class is stored into StringBuilder. The purpose of this class is to manipulate string and save result into...
3 min read
class provides a stream for file operation. It can be used to perform synchronous and asynchronous read and write operations. By the help of FileStream class, we can easily read and write data into file. example: writing single byte into file Let's see the simple example...
2 min read
class is used to read binary information from stream. It is found in System.IO namespace. It also supports reading string in specific encoding. Example Let's see the simple example of BinaryReader class which reads data from dat file. using System; using System.IO; namespace BinaryWriterExample { class Program ...
2 min read
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India