我如何使用DataContractSerializer的序列化时忽略的属性? [英] How can I ignore a property when serializing using the DataContractSerializer?
问题描述
我使用的.NET 3.5SP1和DataContractSerializer的序列化类。在SP1中,他们改变行为,这样你就不必包括类DataContract /的DataMember属性和它只会序列化整个事情。这是我使用的行为,但现在我需要忽略来自串行一个属性。我知道,这样做的一种方法是将DataContract属性添加到类,只是把数据成员属性上的一切,我想包括成员。我有原因,虽然,这不会为我工作。
I am using .NET 3.5SP1 and DataContractSerializer to serialize a class. In SP1, they changed the behavior so that you don't have to include DataContract/DataMember attributes on the class and it will just serialize the entire thing. This is the behavior I am using, but now I need to ignore one property from the serializer. I know that one way to do this is to add the DataContract attribute to the class, and just put the DataMember attribute on all of the members that I want to include. I have reasons, though, that this will not work for me.
所以我的问题是,是否有一个属性或东西,我可以使用,使DataContractSerializer的忽略的属性?
So my question is, is there an attribute or something I can use to make the DataContractSerializer ignore a property?
推荐答案
<一个href=\"http://msdn.microsoft.com/en-us/library/system.runtime.serialization.ignoredatamemberattribute.aspx\">IgnoreDataMemberAttribute?
这篇关于我如何使用DataContractSerializer的序列化时忽略的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!