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

  • Home
  • SEARCH
  • 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 5930135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:30:55+00:00 2026-05-22T14:30:55+00:00

I previously asked the question How to save/restore serializable object to/from file? that solution

  • 0

I previously asked the question How to save/restore serializable object to/from file? that solution works great when I know what type of object I will be saving.

It will be nice if I could save an object of unknown type.

Anyways I am looking to do something like:

[Serializable]
MyCustomClass
{
   // properties. I don't know which properties this class has. I might pass a different class. 
}


public void saveObjectInComputer(object obj, string pathWhereToSaveObject)
{
     // code
}

 public object deserializeObject(string pathWhereObjectIsLocated)
 {
      // code to retrive object
      // ...

      return object;
 }

static void Main(string[] args)
{
     List<MyCustomClass> myList = new List<MyCustomClass>();
     myList.add(new MyCustomClass { "properties go here" } );

     saveObjectInComputer(myList, @"C:\Temp\object.txt");

     // code  

     // Later it will be nice if I could retrive the object 

     object a = deserializeObject(@"C:\Temp\object.txt");

     // then cast a to List<MyCustomClass>

}

And later if I construct a list of cars or a list of people I could use the same method instead of constructing a new method for each. Moreover later I know that the method I am looking for will return an object and I could cast that object to the type that I am currently working with.

  • 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-22T14:30:55+00:00Added an answer on May 22, 2026 at 2:30 pm

    You cannot serialize an object that has not been marked with the Serializable attribute easily, so the short answer is no.

    If you’re willing to step into moderately difficult code, you could use reflection and devise a custom format to save states with, using exceptions for things like indexed properties, etc.. You might as well just not, though.

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

Sidebar

Related Questions

From this previously asked question , I have noticed that when I move a
Refering to a previously asked question , I would like to know how to
Hi guys i previously asked a question and got a good solution. here is
Previously, I asked the question . The problem is the demands of our file
I asked a similar question about this previously, but I did not specify that
Previously I asked this question: Read quicktime movie from servlet in a webpage? Basically
I previously asked this question here: Stop user from using enter to pass a
I'm deleting a previously asked question and asking again more succinctly now that I
I recently asked a question regarding how to save large python objects to file.
Previously I asked a question here . That problem solved but there are error

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.