I\'m using WCF service in my application. I need to return a custom object in the service class. The method is as follows:
IService.cs:
[OperationContract]
You should return an instance of a class that is marked with the DataContract
attribute:
[DataContract]
public class MyClass
{
[DataMember]
public string MyString {get; set;}
}
Now change your service interface like so:
[OperationContract]
MyClass GetMyClass();
And your service:
public MyClass GetMyClass()
{
return new MyClass{MyString = "Test"};
}