Reputation: 894
I have a WCF method which compiles fine with a nullable int as a parameter. However, when I reference the service from another project, it expects an ordinary int as a parameter. From reading other stackoverflow threads it seems that it is possible to have a nullable int parameter, however, I cannot work out how to implement it.
My code is as follows:
[ServiceContract]
public interface IService
{
[OperationContract]
string CompletePayment(int paymentType, int? userId)
}
public class Service : IService
{
public string CompletePayment(int paymentType, int? userId)
{
return "it worked";
}
}
Upvotes: 1
Views: 3601
Reputation: 9806
int?
is just syntactic sugar for Nullable<int>
and I think there are some restrictions when using generics in service contracts. See this answer: Can a WCF service contract have a nullable input parameter?
Upvotes: 1