开发者

How to specify a NonSerialized field with public accessors for XML Serialization

How do you specify a NonSerialized field with pu开发者_StackOverflowblic accessors for XML Serialization?

[NonSerialized]
public String _fooBar;
//Declaring the property here will serialize the _fooBar field
public String FooBar
{
    get { return _fooBar; }
    set { _fooBar = value; }
}


Properties don't get serialized by BinaryFormatter, only fields. The [NonSerialized] attribute has no meaning for XML serialization. Use [XmlIgnore] instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜