0

What is the exact advantages of the DataMember attribute? What is the difference between a serialized Field and a Field with the DataMember attribute. A friend told there is some performance wise gains?

EDIT: Consider this example:

[Serializable] 
public class MyObject { 
public int num; 
public String str; 
}

public class MyObject { 
[DataMember]
public int num; 
[DataMember]
public String str; 
}
QuantumSec
  • 39
  • 8
  • 2
    [`[DataMember]`](http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute.aspx) allows for opt-in serialization of fields in the data contract serialization model. The only impact on performance I can think of is that serialization will take more time if there are more fields to serialize, so you may want to avoid serializing fields you do not need. – Frédéric Hamidi Sep 15 '14 at 08:34
  • Have you considered reading the documentation? The one for the DataMember attribute clearly saying what it is for? – TomTom Sep 15 '14 at 08:44
  • Not just considered - been there done that. Let me elaborate on my question. See edit. – QuantumSec Sep 15 '14 at 08:55

0 Answers0