V3nom's
  • Welcome
  • Getting Started
    • CEH v13
    • Basics of Networking
      • Network Models
        • Application Layer in OSI ->
        • Presentation Layer in OSI ->
          • Comprehensive list of character encoding formats
        • Session Layer in OSI ->
        • Transport Layer in OSI ->
        • Network Layer in OSI ->
        • Data Link Layer in OSI ->
        • Physical Layer ->
    • Arch Linux Installation Guide
    • How to add VBoxLinuxAdditions.run in Debian Based Linux Distros
    • C# Programming Language
  • Research Papers
    • Word Embedding for Anomaly Detection
    • Build your own Redis
    • Blockchain Technology
    • Interactive blocks
    • OpenAPI
    • Integrations
  • Risk Analysis & Mitigation Notes
    • Risk Analysis & Mitigation
      • Unit 1: An Introduction to Risk Management
      • Unit 2: The Threat Assessment Process
      • Unit 3: Vulnerability Issues
      • Unit 4 ( Risk Analysis & Mitigation )
      • Unit 5 ( Risk Analysis & Mitigation )
  • Ethical Hacking
    • Ethical Hacking Syllabus
      • Unit I: Introduction ( English )
      • Unit I: Introduction ( Hinglish )
      • Unit II: The Business Perspective ( English )
      • Unit II: The Business Perspective ( Hinglish )
      • Unit III: Preparing for a Hack ( English )
      • Unit III: Preparing for a Hack ( Hinglish )
      • Unit IV: Enumeration ( English )
      • Unit IV: Enumeration ( Hinglish )
      • Unit V: Deliverables ( English )
      • Unit V: Deliverables ( Hinglish )
  • .NET Framework Notes
    • .NET Framework Syllabus
      • Unit - I ( Hinglish Version )
      • Unit - I ( English - Version for exams )
      • Unit - II ( Hinglish Version - For Understanding )
      • Unit - II (English Version - for papers)
      • Unit - III ( Hinghlish Version )
      • Unit - III ( English - Version )
      • Unit - IV ( Hinglish Version )
      • Unit - IV ( English Version )
      • Unit - V ( Hinglish Version )
      • Unit - V ( English Version )
  • IOT
    • unit 1
    • unit 2
    • unit 3
    • unit 4
    • unit 5
  • AD-Hoc and Wireless Networks
    • Unit 1 ( Hinglish )
    • unit 2 Hinglish
    • All assignments answers with questions
    • Mind Maps for All Questions
    • Page
  • Distributed Systems
    • Unit 1
    • Unit 2
    • Unit 3
    • Unit 4
    • Unit 5
  • Group 1
    • 1’s and 2’s Complement
    • Direct Memory Access
    • Register Transfer Level
    • Interrupt-Based Input/Output (I/O)
    • Memory and CPU Design
    • Instruction Cycle
    • Addressing Modes
    • Pipelining
    • Three Types of Hazards
    • All Types of Differences Tables
    • Parallel Processing
    • Addition/Subtraction Conversion
    • Data Representation
    • Page 1
Powered by GitBook
On this page
  1. .NET Framework Notes
  2. .NET Framework Syllabus

Unit - IV ( Hinglish Version )

UNIT IV: Object Serialization aur Remoting, ADO.NET, aur C# Windows Forms ke Data Control


Object Serialization aur Remoting

Serialization aur remoting .NET ka use karke objects ko store, transmit, aur reconstruct karne ke liye kiya jata hai.

  • Serialization: Object ko ek aise format me convert karta hai jo save ya transmit ho sake.

  • Remoting: Applications ke beech communication enable karta hai.

System.IO Namespace

System.IO namespace data streams aur files ko read, write aur manage karne ke liye types provide karta hai.

  1. Streams:

    • Stream ek abstract class hai jo data transfer ke liye use hoti hai.

    • Common Streams:

      • FileStream: Files ke saath kaam karta hai.

      • MemoryStream: Data ko memory me store karta hai.

      • NetworkStream: Network par communicate karta hai.

  2. TextWriter aur TextReader:

    • TextWriter: Text data ko stream me write karta hai (e.g., StreamWriter).

    • TextReader: Text data ko stream se read karta hai (e.g., StreamReader).

  3. BinaryWriter aur BinaryReader:

    • BinaryWriter: Data ko binary format me stream par write karta hai.

    • BinaryReader: Stream se binary data read karta hai.

    Example of Binary Read/Write:

    using (BinaryWriter writer = new BinaryWriter(File.Open("data.bin", FileMode.Create)))
    {
        writer.Write(42);
        writer.Write("Hello");
    }
    
    using (BinaryReader reader = new BinaryReader(File.Open("data.bin", FileMode.Open)))
    {
        Console.WriteLine(reader.ReadInt32());
        Console.WriteLine(reader.ReadString());
    }

Serialized Object Persistence aur Formatters

Serialization objects ko byte stream me convert karta hai jo store ya transmit ho sake, aur deserialization byte stream se object ko reconstruct karta hai.

  1. Serialization ke Types:

    • Binary Serialization: Compact aur efficient storage ke liye BinaryFormatter ka use hota hai.

    • XML Serialization: Objects ko XML format me convert karta hai (XmlSerializer ka use karke).

    • JSON Serialization: Objects ko JSON me convert karta hai (JsonSerializer ka use karke).

  2. BinaryFormatter Example:

    using System.Runtime.Serialization.Formatters.Binary;
    using System.IO;
    
    BinaryFormatter formatter = new BinaryFormatter();
    using (FileStream fs = new FileStream("objectData.bin", FileMode.Create))
    {
        MyClass obj = new MyClass { Id = 1, Name = "Test" };
        formatter.Serialize(fs, obj);
    }
    
    using (FileStream fs = new FileStream("objectData.bin", FileMode.Open))
    {
        MyClass obj = (MyClass)formatter.Deserialize(fs);
    }

Remoting

Remoting alag-alag application domains, processes, ya machines ke beech communication ke liye kaam karta hai.

  1. Remoting ke Basics:

    • Objects jaise ki MarshalByRefObject ka use hota hai data ko pass karne ke liye.

    • TCP ya HTTP channels ka use karke communicate karta hai.

  2. Remoting Configuration:

    • Server-Side: Remoting service me object ko host karna.

    • Client-Side: Server se object consume karna.


ADO.NET

ADO.NET ek data access technology hai jo databases ke saath connect, retrieve, manipulate, aur update karne me madad karta hai.

Connected aur Disconnected Scenarios

  1. Connected Scenario:

    • Database ke saath active connection chahiye hota hai operations ke liye.

    • Objects jaise SqlConnection, SqlCommand, aur SqlDataReader ka use hota hai.

  2. Disconnected Scenario:

    • Data locally DataSet me store hota hai.

    • Offline changes karne ki permission deta hai jo baad me update ki ja sakti hai.

Key ADO.NET Objects

  1. SqlConnection: Database ke saath connection banata hai.

    SqlConnection conn = new SqlConnection("your_connection_string");
    conn.Open();
    conn.Close();
  2. SqlCommand: Query ya command execute karne ke liye use hota hai.

    SqlCommand cmd = new SqlCommand("SELECT * FROM Table", conn);
  3. SqlDataReader: Row-by-row data read karta hai database se.

    SqlDataReader reader = cmd.ExecuteReader();
    while (reader.Read())
    {
        Console.WriteLine(reader["ColumnName"]);
    }
  4. DataSet: Data ka in-memory representation hai.

    DataSet ds = new DataSet();
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Table", conn);
    adapter.Fill(ds);
  5. SqlDataAdapter: Database aur DataSet ke beech bridge ka kaam karta hai.


C# Windows Forms for Data Control

Windows Forms alag-alag controls provide karta hai jo data display aur manage karne ke liye use hote hain.

Key Controls for Data Control

  1. GridView:

    • Tabular format me data display karta hai.

    • Data ko DataSource ke saath bind kiya ja sakta hai.

  2. DataSource:

    • Controls (jaise GridView) ke liye data source ka kaam karta hai.

  3. DataBinding:

    • UI controls ko data sources ke saath link karta hai.

    • Example:

      textBox1.DataBindings.Add("Text", dataTable, "ColumnName");

ADO.NET in Windows Forms

  • Controls jaise GridView ko DataSet ya DataTable ke saath connect karta hai.

  • Example:

    DataSet ds = new DataSet();
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Table", conn);
    adapter.Fill(ds);
    dataGridView1.DataSource = ds.Tables[0];

Summary

  • Object Serialization objects ko save ya transmit karne ke liye convert karta hai, aur formatters jaise BinaryFormatter ya JsonSerializer ka use hota hai.

  • Remoting alag processes ya networks ke beech communication enable karta hai.

  • ADO.NET databases ke saath interact karne ka ek strong framework provide karta hai, jo connected (SqlCommand, SqlDataReader) aur disconnected (DataSet, SqlDataAdapter) operations ko support karta hai.

  • C# Windows Forms controls jaise GridView aur databinding mechanisms ke madhyam se data ko user-friendly interface me display aur manage karne deta hai.

PreviousUnit - III ( English - Version )NextUnit - IV ( English Version )

Last updated 4 months ago