So, I've been looking at all kinds of examples of a WCF class that is to be serialized. I'd like to define all my DataContracts and DataMembers in interfaces and then allow implementation that suits the environment. Is this possible, and if so, are there drawbacks to this approach?
[DataContract]
public class Contact
{
[DataMember]
public int Roll { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Address { get; set; }
[DataMember]
public int Age { get; set; }
}
Can instead do this:
[DataContract]
public interface IContact
{
[DataMember]
int Roll { get; set; }
[DataMember]
string Name { get; set; }
[DataMember]
string Address { get; set; }
[DataMember]
int Age { get; set; }
}
public class Contact :IContact
{
public int Roll { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public int Age { get; set; }
}