I have some dto object which I want to sent over the wire using wcf. In this simple case it has FirstName, LastName and Name. Name returns firstname and lastname in conjuction.
Normally I would'nt use settter for Name property but I have to since otherwise it cannot be serialized, so I tried with internal but I'm getting error on Name setter
An unhandled exception of type 'System.StackOverflowException' occurred in LibSys.WebServices.dll
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
[DataMember]
public string Name {
get { return string.Format("{0} {1}", FirstName, LastName); }
internal set { Name = value; }
}
Nameshould not be serialized at all. You already serializeLastNameandFirstName. When you deserialize your object and callNameproperty it will calculate its value from those 2 properties.