C Sharp Deserialization

C# Deserialization The reverse process of serialization is known as deserialization in C# programming. Thus the object can be read from a byte stream. To deserialize the stream, we are using the BinaryFormatter.Deserialize(stream) method. Example: using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; [Serializable] class Employee { public int ID; public string Name; public Employee(int ID, string … Read more

Categories C#

C Sharp Serialization

C# Serialization To convert an object into a byte stream to be saved to memory, file or database, the process of serialization is used in C#. In remote applications, it is used internally. C# SerializableAttribute: The SerializableAttribute attribute is applied to the type, to serialize the object. Without this, the SerializationException exception will be thrown … Read more

Categories C#

C Sharp DirectoryInfo Class

C# DirectoryInfo Class Being a part of the System.IO namespace, the DirectoryInfo class in C# facilitates various constructors, methods, and properties to perform operations related to directory and subdirectory, i.e., to create, delete and move a directory or subdirectory. The DirectoryInfo class in C# cannot be inherited, because it is a sealed class. C# DirectoryInfo … Read more

Categories C#

C Sharp FileInfo Class

C# FileInfo Class The FileInfo class in C# facilitates properties and methods to deal with the file and its operations, i.e., to create, delete and read a file. Being a part of the System.IO namespace, it writes data to the file using the StreamWriter class. C# FileInfo Class Signature: [SerializableAttribute] [ComVisibleAttribute(true)] public sealed class FileInfo … Read more

Categories C#

C Sharp StringReader Class

C# StringReader Class Being a subclass of the TextReader class, the StringReader class facilitates constructors and methods to perform read operations and is thus used for reading data written by the StringWriter class, synchronously or asynchronously. C# StringReader Signature: [SerializableAttribute] [ComVisibleAttribute(true)] public class StringReader : TextReader C# StringReader Constructors: Constructors Uses StringReader(String) To initialize a … Read more

Categories C#

C Sharp StringWriter Class

C# StringWriter Class Being a derived class of the TextWriter class, the StringWriter class is used for writing and dealing with the string data instead of the files with a purpose to manipulate the string data and to store the result into the StringBuilder. StringWriter Class Signature: [SerializableAttribute] [ComVisibleAttribute(true)] public class StringWriter : TextWriter C# … Read more

Categories C#

C Sharp BinaryReader

C# BinaryReader Found in System.IO namespace, the C# BinaryReader class supports specific encoding for reading a string and is thus used for reading the binary information from a stream. Example: using System; using System.IO; namespace Example { class content { static void Main(string[] args) { WriteFile(); ReadFile(); Console.ReadKey(); } static void WriteFile() { using (BinaryWriter … Read more

Categories C#

C Sharp BinaryWriter

C# BinaryWriter Found in System.IO namespace, the C# BinaryWriter class supports specific encoding for writing a string and is thus used for writing the binary information into a stream. Example: using System; using System.IO; namespace Example { class content { static void Main(string[] args) { string fileName = "d\\bfile.dat"; using (BinaryWriter bw = new BinaryWriter(File.Open(fileName, … Read more

Categories C#

C Sharp TextReader

C# TextReader Found in System.IO namespace, the C# TextReader class is used as a reader for reading text or sequential series of characters. Example: using System; using System.IO; namespace Example { class content { static void Main(string[] args) { using (TextReader reader = File.OpenText("d:\\file.txt")) { Console.WriteLine(reader.ReadToEnd()); } } } }using System; using System.IO; namespace Example … Read more

Categories C#

C Sharp TextWriter

C# TextWriter Being an abstract class, the C# TextWriter class is found in System.IO namespace to be used for writing text or sequential series of characters into a file. Example: using System; using System.IO; namespace Example { class content { static void Main(string[] args) { using (TextWriter writer = File.CreateText("d:\\file.txt")) { writer.WriteLine("Hello World."); writer.WriteLine("Good Morning."); … Read more

Categories C#