我有一个静态方法(在命名空间 Common 中的 CommonHelper 类中),我想使用它来包含具有如下定义的静态资源:
public static string GetUrlForStaticResource(
String fileName, String folder="scripts", bool preventCaching=false)
您可以看到“folder”和“preventCaching”参数是可选的,因为它们具有默认值。当我从 .cs 文件调用该方法时,它工作正常,但在我的 .aspx 中,我尝试了以下操作并收到错误CS1501: No overload for method 'GetUrlForStaticResource' requires '1' arguments:
<div>Example: <%= Common.CommonHelper.GetUrlForStaticResource("test.js") %></div>
如果我提供所有参数,它可以正常工作:
<div>Example: <%= Common.CommonHelper.GetUrlForStaticResource("test.js", "scripts", false) %>
</div>
我究竟做错了什么?.aspx 中没有可选参数吗?