How can we serialize the properties defined with private field?
<pre><code>public class NetworkCredentialHolder
{
    public NetworkCredentialHolder()
    {
        _networkCred = new NetworkCredential();
    }

    public string UserName
    {
        get { return _networkCred.UserName; }
        set { _networkCred.UserName = value; }
    }

    public string Domain
    {
        get { return _networkCred.Domain; }
        set { _networkCred.Domain = value; }
    }
}

public class SPS2003NetworkConfiguration
{
public SPS2003NetworkConfiguration()
    {
        _targetCredentials = new NetworkCredentialHolder();
    }

    private NetworkCredentialHolder _targetCredentials;
}

class Program
{
    static void Main(string[] args)
    {
        var netConfiguration = new SPS2003NetworkConfiguration();
        netConfiguration.SetGlobalCredentials("sanz", "pass@word1TestPassed");

        var sb = new StringBuilder();
        var writer = new StringWriter(sb);

        XmlSerializer serializer = new XmlSerializer(typeof(SPS2003NetworkConfiguration));
        serializer.Serialize(writer, netConfiguration);

        XmlDocument doc = new XmlDocument();
        doc.LoadXml(sb.ToString());

        XmlNodeReader reader = new XmlNodeReader(doc.DocumentElement);
        XmlSerializer serializer = new XmlSerializer(typeof(SPS2003NetworkConfiguration));

        object obj = serializer.Deserialize(reader);

        var netConfiguration = (SPS2003NetworkConfiguration)obj;
        var encryptedPwd =      netConfiguration.TargetCredentials.SecurePassword;
    }
}
</code></pre>

<p>Hi, Here I have created </p>

<pre><code>private NetworkCredentialHolder _targetCredentials;
</code></pre>

<p>when I created <code>_targetCredntials</code> as private, the properties defined under <code>NetworkCrendtialHolder</code> like <code>UserName</code>, <code>Domain</code> are not serialized unless <code>_targetCredentials</code> is defined as public. Is there any way I can serialize <code>UserName</code>, <code>Domain</code> while keeping <code>_targetCredential</code> as private ?? </p>
