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 6789645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:37:45+00:00 2026-05-26T17:37:45+00:00

I have an Class structure like this: class A { Dictionary<UInt64, B> listB; method1(){}

  • 0

I have an Class structure like this:

class A { 
   Dictionary<UInt64, B> listB;
   method1(){}
   methodN(){}
}

class B {       

   Dictionary<UInt32, C> listC;
   Dictionary<UInt32, E> listE;
   List<F> listF;
   method1(){}
   methodN(){}
}

class C { 
   Dictionary<UInt32, D> listD;
   method1(){}
   methodN(){}
}

class D { 
   method1(){}
   methodN(){}
}   

class E { 
   method1(){}
   methodN(){}
}    

class F { 
   method1(){}
   methodN(){}
}

Class A is the main Class, and B is a sub class of A. All other classes are sub class of B.

I want to serialize class A with all sub Classes.

How can I serialize these Objects?

Thank You!

  • 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-26T17:37:46+00:00Added an answer on May 26, 2026 at 5:37 pm

    since you said you want to do it over sockets, probably something like this:

    public void SerializeObject(NetworkStream stream, ObjectToSerialize objectToSerialize)
    {
       varbFormatter = new BinaryFormatter();
       bFormatter.Serialize(stream, objectToSerialize);
       stream.Close();
    }
    
    public ObjectToSerialize DeSerializeObject(NetworkStream stream)
    {
       ObjectToSerialize objectToSerialize;
       var bFormatter = new BinaryFormatter();
       objectToSerialize = (ObjectToSerialize)bFormatter.Deserialize(stream);
       stream.Close();
       return objectToSerialize;
    }
    

    edit: note: code is untested. it probably needs some modifications depending on your stream and such

    And like Brad commented, give all your classes the SerializableAttribute.

    [Serializable]
    class A { 
    ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four level data structure defined like this: Dictionary<Type1, Dictionary<Type2, Dictionary<Type3, List<Type4>>>> The
I have a data structure that represents C# code like this: class Namespace: string
I would like to have a structure like this: Mapping class int ID {get;set;}
I have a class structure like this: class A { public someFunction() { $objectB
I have a class like this: [Serializable] public class Structure { #region Constants and
I have a table that has structure like this (td omitted) <table> <tr class=header>...</tr>
I have a class structure for a role playing game which looks like this...
I have a div structure like this [simple menu]: <div class=float menuA> <div class=float
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public
I have a class structure like abstract class Animal { public Animal(){ //init stuff..

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.