in Search
     
Latest post 12-27-2006 9:45 PM by jong.net. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 12-27-2006 2:34 AM

    • jong.net
    • Top 50 Contributor
    • Joined on 08-25-2006
    • Pasig
    • Posts 27
    • Points 450

    Xml Serialization of static fields

    I can't open the Web Services and XML-Related topics thread section so I posted my this thread here..

    I have a class that has the following contents :

    [Serializable()]

    public class InstrumentConfiguration

    {

    [XmlElement("GPIBAddress")]

    public static string gpibAddress;

    [XmlElement("DCSourceAddress")]

    public static string dcSourceAddress;

    [XmlElement("DMMAddress")]

    public static string dmmAddress;

    // Static Constructor

    static InstrumentConfiguration()

    {}

    // Default Constructor

    public InstrumentConfiguration()

    {}

    }

    Questions :

    1. Can static fields like the one above be serialized?

    2. Are public properties good substitutes for serializing private fields? Is this a good practice?

    3. Are static classes serializable? I don't see a way to pass them in the XmlSerializer.Serialize() method since the object parameter must be an instance of a class?

     

    I'm actually implementing a settings file for class entities which can be saved through xml files and possibly through a database. Do you guys have a suggestion on how I can implement this.

    Success is 1% Inspiration and 99% Perspiration.. - T. Edison -
    • Post Points: 20
  • 12-27-2006 3:31 PM In reply to

    • cruizer
    • Top 10 Contributor
    • Joined on 12-14-2005
    • Singapore
    • Posts 944
    • Points 22,590

    Re: Xml Serialization of static fields

    as far as i know, static members are not serialized because they are not tied to an instance anyway.
    http://devpinoy.org/blogs/cruizer
    Naglalayong buksan at palayain ang kamalayan ng Pinoy .NET developer
    • Post Points: 20
  • 12-27-2006 9:45 PM In reply to

    • jong.net
    • Top 50 Contributor
    • Joined on 08-25-2006
    • Pasig
    • Posts 27
    • Points 450

    Re: Xml Serialization of static fields

    Here's the equivalent thread in MSFORUMS.PH --> XML Serialization of static fields
    Success is 1% Inspiration and 99% Perspiration.. - T. Edison -
    • Post Points: 5
Page 1 of 1 (3 items)