DataContract
is a formal agreement between a service and client that abstractly describe the
data to be exchanged.
DataContract
are used to describe the data types used by service.
DataContract
can be explicit or implicit.
It is not necessary
to use DataContract if you are using simple/implicit data type i.e. int, string
.
DataContract
is necessary when you want to use complex data type.
Example:-
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello
";
[DataMember]
public bool BoolValue
{
get { return
boolValue; }
set { boolValue = value;
}
}
[DataMember]
public string
StringValue
{
get { return
stringValue; }
set { stringValue = value;
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.