Im following a guide which tell me to create a simple class file and add following code
[DataContract]
public class Footballers
{
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
[DataMember]
public DateTime BirthDate { get; set; }
}
I get an error around [datacontract] and [datamember] saying type or namespace can not be found.
Firstly I guess what namespace do Need to include ?
Secondly are these things necessary ?
Lastly what do they do, I have never seen them in a class file before ?
If you’re using Visual Studio, right click on DataContract or DataMember, you should see Resolve at the top of the context menu, it’ll let you automatically add the namespace to the using declarations at the top of the file.
These attributes are necessary for creating data type that will be exposed via a WCF service.