【发布时间】:2013-05-21 07:24:12
【问题描述】:
我写了一个带有可选参数的网络方法。
[WebMethod]
public void EmailSend(string from, string to, string cc = null, string bcc = null, string replyToList = null, string subject = null, string body = null, bool isBodyHtml = false , string[] attachmentNames = null, byte[][] attachmentContents = null)
{
.....
}
我在客户端应用程序中调用此方法
EmailServiceManagement.EmailService es = new EmailServiceManagement.EmailService();
es.EmailSend(from, to,null,null,null,subject,body,true,attName,att); //this works
但是
es.EmailSend(from,to); // this isn't working. According to c# optional parameter syntax it must work.
我做错了什么?
【问题讨论】:
-
Web 方法应该独立于平台/语言,并且每种语言都不必支持可选参数。所以你的第一个版本是正确的。
-
@I4V 所以在web方法中使用可选参数没有任何意义。