Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 673827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:38:19+00:00 2026-05-14T00:38:19+00:00

I am planning to use serialization to do clone. I have to make my

  • 0

I am planning to use serialization to do clone. I have to make my class ISerializable. But how about its super classes and all referenced variable classes? do I need to make them all ISerializable?

If I use ISerializable. I have to implement the GetObjectData(), what I should put inside that method? leave it empty is ok?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:38:19+00:00Added an answer on May 14, 2026 at 12:38 am

    Unless you mark the class with the
    [Serializable] attribute, this
    interface must be implemented by all
    classes with serialized instances. Use
    the ISerializable interface if you
    want your class to control its own
    serialization and de-serialization.

    The GetObjectData() let you control the serialization process.

    GetDataObject, to which you pass a
    SerializationInfo object and a
    StreamingContext object. The
    GetDataObject method will then
    populate the SerializationInfo object
    with the data necessary for the
    serialization of the target object.

    Example:

    public Employee(SerializationInfo info, StreamingContext ctxt)
    {
        //Get the values from info and assign them to the appropriate properties
        EmpId = (int)info.GetValue("EmployeeId", typeof(int));
        EmpName = (String)info.GetValue("EmployeeName", typeof(string));
    }
    
    public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
    {
        //You can use any custom name for your name-value pair. But make sure you
        // read the values with the same name. For ex:- If you write EmpId as "EmployeeId"
        // then you should read the same with "EmployeeId"
        info.AddValue("EmployeeId", EmpId);
        info.AddValue("EmployeeName", EmpName);
    }
    

    The example above show you how to deserialize and serialize. As you can see GetObjectData is required to deserialize. If you leave it empty, your object won’t have the desire values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am planning to try to use XML Serialization in C# but I am
I was planning to use url routing for a Web Forms application. But, after
I am planning to use coverflow control in my Silverlight application, but I am
I am planning to use PHP's autoload function to dynamicly load only class files
I am planning to use Locomotive for a project...But as the official website says
I am planning to use VMWare workstation for installing linux. But my use case
I am planning to use a Grid system for a site, but I'd like
I'm planning to use Serialization to save the Bean modified by user--to store the
I am planning to use Hadoop on EC2. Since we have to pay per
I'm planning to use Sqlite but I don't know how to integrate it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.