Can't use optional parameters when implementing an interface for a WCF

后端 未结 5 695
刺人心
刺人心 2021-01-11 10:19

In my interface I have declared this.

[OperationContract]
[WebGet]
String GetStuff(String beep, String boop = \"too lazy to type\");

I impl

5条回答
  •  执念已碎
    2021-01-11 10:41

    You can do it like this:

    [DataContract]
    public class GetStuffParams
    {
        [DataMember]
        string beep {get; set; }
    
        [DataMember]
        string boop  {get; set;}
    
    
        public GetStuffParams() { boop = "too lazy to type"; }
    }
    
    
    [OperationContract]
    [WebGet]
    String GetStuff(GetStuffParams stuffParams);
    

提交回复
热议问题