Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. [Serializable] for class inside class

[Serializable] for class inside class

Scheduled Pinned Locked Moved C#
helpphpdatabasecomxml
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roland Bar
    wrote on last edited by
    #1

    Hi, I have some Problems with Serialization: I have a class B that is inside a class A:

    public class A
    {
        [Serializable]
        public class B
        {
            public int Number;
        }
    }
    

    When I try to serialize/deserialize it with the XML Serializer it does not work. Is it possible to serialize a class that is inside a class (so I have to search the bug elsewhere) or is it impossible (so I have to change the structure of the classes)? Thanks Roland


    Hi! I'm a signature virus. Copy me into your sig file and help me spread!

    Follow your Euro notes in their tracks

    R 1 Reply Last reply
    0
    • R Roland Bar

      Hi, I have some Problems with Serialization: I have a class B that is inside a class A:

      public class A
      {
          [Serializable]
          public class B
          {
              public int Number;
          }
      }
      

      When I try to serialize/deserialize it with the XML Serializer it does not work. Is it possible to serialize a class that is inside a class (so I have to search the bug elsewhere) or is it impossible (so I have to change the structure of the classes)? Thanks Roland


      Hi! I'm a signature virus. Copy me into your sig file and help me spread!

      Follow your Euro notes in their tracks

      R Offline
      R Offline
      Roland Bar
      wrote on last edited by
      #2

      OK, found the Problem: My class contains an IPAddress that can not be serialized by the XML Serializer because there is no default constructor. I only looked if the Attribute Serializable is set... I tested and saw that with a simple class like the onein my example there is no problem with serializing a class inside a class... Greets Roland


      Hi! I'm a signature virus. Copy me into your sig file and help me spread!

      Follow your Euro notes in their tracks

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups